Fix: disable auto-open after door opens, re-enable on leaving gps_home_high zone

This commit is contained in:
2026-08-09 16:38:38 +07:00
parent fbea67ed55
commit ccc4cc0190
+31 -23
View File
@@ -1,15 +1,15 @@
intercom: intercom:
shell_command: shell_command:
update_goodline_token: "python3 /config/scripts/update_goodline_token.py {{ code }}" update_goodline_token: "python3 /config/scripts/update_goodline_token.py {{ code }}"
open_goodline_door: 'curl -s -X GET "https://api-video.goodline.info/ords/mobile/onlinedozor/gates/Kemerovo_Serebryanyy_bor_4a_Podezd_1/open-door" -H "token: $(cat /config/scripts/goodline_token.txt)" -H "origin: https://video.online-dozor.ru" -H "referer: https://video.online-dozor.ru/" -H "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" -H "accept: application/json, text/plain, */*"' open_goodline_door: 'curl -s -X GET "https://api-video.goodline.info/ords/mobile/onlinedozor/gates/Kemerovo_Serebryanyy_bor_4a_Podezd_1/open-door" -H "token: $(cat /config/scripts/goodline_token.txt)" -H "origin: https://video.online-dozor.ru" -H "referer: https://video.online-dozor.ru/" -H "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" -H "accept: application/json, text/plain, */*"'
command_line: command_line:
- sensor: - sensor:
name: "Goodline Camera URL" name: "Goodline Camera URL"
unique_id: goodline_cam_url unique_id: goodline_cam_url
command: "python3 /config/scripts/get_camera.py" command: "python3 /config/scripts/get_camera.py"
scan_interval: 300 scan_interval: 300
template: template:
- sensor: - sensor:
- name: "Расстояние до подъезда" - name: "Расстояние до подъезда"
@@ -18,19 +18,19 @@ intercom:
state: > state: >
{{ distance('device_tracker.google_maps_108918666344169166438', 'zone.intercom') | multiply(1000) | round(0) }} {{ distance('device_tracker.google_maps_108918666344169166438', 'zone.intercom') | multiply(1000) | round(0) }}
icon: mdi:map-marker-distance icon: mdi:map-marker-distance
- name: "Дистанция (Телефон)" - name: "Дистанция (Телефон)"
unique_id: distance_to_intercom_phone unique_id: distance_to_intercom_phone
unit_of_measurement: "м" unit_of_measurement: "м"
state: > state: >
{{ distance('device_tracker.cph2573_2', 'zone.intercom') | multiply(1000) | round(0) }} {{ distance('device_tracker.cph2573_2', 'zone.intercom') | multiply(1000) | round(0) }}
icon: mdi:cellphone-marker icon: mdi:cellphone-marker
input_boolean: input_boolean:
intercom_auto_open: intercom_auto_open:
name: "Автооткрытие двери" name: "Автооткрытие двери"
icon: mdi:door-open icon: mdi:door-open
automation: automation:
# ========================================== # ==========================================
# 1. ПЕРЕХВАТ СМС (Работает ВСЕГДА) # 1. ПЕРЕХВАТ СМС (Работает ВСЕГДА)
@@ -53,7 +53,7 @@ intercom:
- service: shell_command.update_goodline_token - service: shell_command.update_goodline_token
data: data:
code: "{{ sms_code }}" code: "{{ sms_code }}"
# ========================================== # ==========================================
# 2. ВКЛЮЧЕНИЕ ТОЧНОГО GPS (Только если Авто ВКЛ) # 2. ВКЛЮЧЕНИЕ ТОЧНОГО GPS (Только если Авто ВКЛ)
# ========================================== # ==========================================
@@ -84,8 +84,8 @@ intercom:
command: "turn_on" command: "turn_on"
ttl: 0 ttl: 0
priority: high priority: high
# ========================================== # ==========================================
# 3. АВТООТКРЫТИЕ ДВЕРИ (Тройное с кнопками) # 3. АВТООТКРЫТИЕ ДВЕРИ (Тройное с кнопками)
# ========================================== # ==========================================
- id: auto_open_at_intercom_zone - id: auto_open_at_intercom_zone
@@ -99,8 +99,6 @@ intercom:
- condition: state - condition: state
entity_id: input_boolean.intercom_auto_open entity_id: input_boolean.intercom_auto_open
state: "on" state: "on"
- condition: template
value_template: "{{ this.attributes.last_triggered == none or (now() - this.attributes.last_triggered).total_seconds() > 300 }}"
action: action:
# Цикл открытия двери: 3 раза с интервалом 7 секунд # Цикл открытия двери: 3 раза с интервалом 7 секунд
- repeat: - repeat:
@@ -112,17 +110,24 @@ intercom:
value_template: "{{ repeat.index < 3 }}" value_template: "{{ repeat.index < 3 }}"
- delay: - delay:
seconds: 5 seconds: 5
# Выключаем автооткрытие — больше не будет работать, пока не выйдешь из gps_home_high
- service: input_boolean.turn_off
target:
entity_id: input_boolean.intercom_auto_open
# Уведомление с кнопками управления # Уведомление с кнопками управления
- service: telegram_bot.send_message - service: telegram_bot.send_message
data: data:
target: -1002006010424 target: -1002006010424
parse_mode: html parse_mode: html
message: "🏠 <b>Зона INTERCOM достигнута!</b>\nДверь открыта 3 раза с интервалом 7 сек." message: "🏠 <b>Зона INTERCOM достигнута!</b>
Дверь открыта 3 раза с интервалом 7 сек.
Автоотключение — выйди из gps_home_high, чтобы включить снова."
inline_keyboard: inline_keyboard:
- "🔔 Домофон:/intercom_menu" - "🔔 Домофон:/intercom_menu"
- "🏠 Главное меню:/menu_back" - "🏠 Главное меню:/menu_back"
# Выключение точного GPS для экономии заряда # Выключение точного GPS для экономии заряда
- service: notify.mobile_app_oneplus12 - service: notify.mobile_app_oneplus12
data: data:
@@ -131,26 +136,29 @@ intercom:
command: "turn_off" command: "turn_off"
ttl: 0 ttl: 0
priority: high priority: high
# ========================================== # ==========================================
# 4. ВЫКЛЮЧЕНИЕ GPS ПРИ ВЫХОДЕ (Работает ВСЕГДА для экономии заряда) # 4. ВЫХОД ИЗ ЗОНЫ gps_home_high
# ========================================== # ==========================================
- id: turn_off_high_accuracy_on_leave # Включаем автооткрытие обратно и выключаем GPS
alias: "gps|turn_off_on_leave" - id: leave_gps_home_high_rearm_auto_open
alias: "gps|leave_gps_home_high_rearm_auto_open"
trigger: trigger:
- platform: zone - platform: zone
entity_id: device_tracker.cph2573_2 entity_id: device_tracker.cph2573_2
zone: zone.gps_home_high zone: zone.gps_home_high
event: leave event: leave
condition:
- condition: state
entity_id: binary_sensor.oneplus12_high_accuracy_mode
state: "on"
action: action:
# Включаем автооткрытие двери
- service: input_boolean.turn_on
target:
entity_id: input_boolean.intercom_auto_open
# Выключаем точный GPS для экономии заряда
- service: notify.mobile_app_oneplus12 - service: notify.mobile_app_oneplus12
data: data:
message: "command_high_accuracy_mode" message: "command_high_accuracy_mode"
data: data:
command: "turn_off" command: "turn_off"
ttl: 0 ttl: 0
priority: high priority: high