Fix: disable auto-open after door opens, re-enable on leaving gps_home_high zone
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
intercom:
|
||||
intercom:
|
||||
shell_command:
|
||||
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, */*"'
|
||||
|
||||
|
||||
command_line:
|
||||
- sensor:
|
||||
name: "Goodline Camera URL"
|
||||
unique_id: goodline_cam_url
|
||||
command: "python3 /config/scripts/get_camera.py"
|
||||
scan_interval: 300
|
||||
|
||||
|
||||
template:
|
||||
- sensor:
|
||||
- name: "Расстояние до подъезда"
|
||||
@@ -18,19 +18,19 @@ intercom:
|
||||
state: >
|
||||
{{ distance('device_tracker.google_maps_108918666344169166438', 'zone.intercom') | multiply(1000) | round(0) }}
|
||||
icon: mdi:map-marker-distance
|
||||
|
||||
|
||||
- name: "Дистанция (Телефон)"
|
||||
unique_id: distance_to_intercom_phone
|
||||
unit_of_measurement: "м"
|
||||
state: >
|
||||
{{ distance('device_tracker.cph2573_2', 'zone.intercom') | multiply(1000) | round(0) }}
|
||||
icon: mdi:cellphone-marker
|
||||
|
||||
|
||||
input_boolean:
|
||||
intercom_auto_open:
|
||||
name: "Автооткрытие двери"
|
||||
icon: mdi:door-open
|
||||
|
||||
|
||||
automation:
|
||||
# ==========================================
|
||||
# 1. ПЕРЕХВАТ СМС (Работает ВСЕГДА)
|
||||
@@ -53,7 +53,7 @@ intercom:
|
||||
- service: shell_command.update_goodline_token
|
||||
data:
|
||||
code: "{{ sms_code }}"
|
||||
|
||||
|
||||
# ==========================================
|
||||
# 2. ВКЛЮЧЕНИЕ ТОЧНОГО GPS (Только если Авто ВКЛ)
|
||||
# ==========================================
|
||||
@@ -84,8 +84,8 @@ intercom:
|
||||
command: "turn_on"
|
||||
ttl: 0
|
||||
priority: high
|
||||
|
||||
# ==========================================
|
||||
|
||||
# ==========================================
|
||||
# 3. АВТООТКРЫТИЕ ДВЕРИ (Тройное с кнопками)
|
||||
# ==========================================
|
||||
- id: auto_open_at_intercom_zone
|
||||
@@ -99,8 +99,6 @@ intercom:
|
||||
- condition: state
|
||||
entity_id: input_boolean.intercom_auto_open
|
||||
state: "on"
|
||||
- condition: template
|
||||
value_template: "{{ this.attributes.last_triggered == none or (now() - this.attributes.last_triggered).total_seconds() > 300 }}"
|
||||
action:
|
||||
# Цикл открытия двери: 3 раза с интервалом 7 секунд
|
||||
- repeat:
|
||||
@@ -112,17 +110,24 @@ intercom:
|
||||
value_template: "{{ repeat.index < 3 }}"
|
||||
- delay:
|
||||
seconds: 5
|
||||
|
||||
|
||||
# Выключаем автооткрытие — больше не будет работать, пока не выйдешь из gps_home_high
|
||||
- service: input_boolean.turn_off
|
||||
target:
|
||||
entity_id: input_boolean.intercom_auto_open
|
||||
|
||||
# Уведомление с кнопками управления
|
||||
- service: telegram_bot.send_message
|
||||
data:
|
||||
target: -1002006010424
|
||||
parse_mode: html
|
||||
message: "🏠 <b>Зона INTERCOM достигнута!</b>\nДверь открыта 3 раза с интервалом 7 сек."
|
||||
message: "🏠 <b>Зона INTERCOM достигнута!</b>
|
||||
Дверь открыта 3 раза с интервалом 7 сек.
|
||||
Автоотключение — выйди из gps_home_high, чтобы включить снова."
|
||||
inline_keyboard:
|
||||
- "🔔 Домофон:/intercom_menu"
|
||||
- "🏠 Главное меню:/menu_back"
|
||||
|
||||
|
||||
# Выключение точного GPS для экономии заряда
|
||||
- service: notify.mobile_app_oneplus12
|
||||
data:
|
||||
@@ -131,26 +136,29 @@ intercom:
|
||||
command: "turn_off"
|
||||
ttl: 0
|
||||
priority: high
|
||||
|
||||
|
||||
# ==========================================
|
||||
# 4. ВЫКЛЮЧЕНИЕ GPS ПРИ ВЫХОДЕ (Работает ВСЕГДА для экономии заряда)
|
||||
# 4. ВЫХОД ИЗ ЗОНЫ gps_home_high
|
||||
# ==========================================
|
||||
- id: turn_off_high_accuracy_on_leave
|
||||
alias: "gps|turn_off_on_leave"
|
||||
# Включаем автооткрытие обратно и выключаем GPS
|
||||
- id: leave_gps_home_high_rearm_auto_open
|
||||
alias: "gps|leave_gps_home_high_rearm_auto_open"
|
||||
trigger:
|
||||
- platform: zone
|
||||
entity_id: device_tracker.cph2573_2
|
||||
zone: zone.gps_home_high
|
||||
event: leave
|
||||
condition:
|
||||
- condition: state
|
||||
entity_id: binary_sensor.oneplus12_high_accuracy_mode
|
||||
state: "on"
|
||||
action:
|
||||
# Включаем автооткрытие двери
|
||||
- service: input_boolean.turn_on
|
||||
target:
|
||||
entity_id: input_boolean.intercom_auto_open
|
||||
|
||||
# Выключаем точный GPS для экономии заряда
|
||||
- service: notify.mobile_app_oneplus12
|
||||
data:
|
||||
message: "command_high_accuracy_mode"
|
||||
data:
|
||||
command: "turn_off"
|
||||
ttl: 0
|
||||
priority: high
|
||||
priority: high
|
||||
|
||||
Reference in New Issue
Block a user