Обновить includes/packages/intercom.yaml

This commit is contained in:
2026-08-09 16:26:55 +07:00
parent f7d8f74e31
commit fbea67ed55
+156
View File
@@ -0,0 +1,156 @@
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: "Расстояние до подъезда"
unique_id: distance_to_intercom
unit_of_measurement: "м"
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. ПЕРЕХВАТ СМС (Работает ВСЕГДА)
# ==========================================
- id: catch_onlinedozor_sms_webhook
alias: "sms|catch_onlinedozor_code"
mode: single
trigger:
- platform: webhook
webhook_id: "goodline_sms_hook"
allowed_methods: [POST]
local_only: true
action:
- variables:
sms_code: "{{ trigger.json.text | regex_findall_index('[0-9]{4}') }}"
- service: telegram_bot.send_message
data:
chat_id: -1002006010424
message: "🔑 <b>Код:</b> <code>{{ sms_code }}</code>"
- service: shell_command.update_goodline_token
data:
code: "{{ sms_code }}"
# ==========================================
# 2. ВКЛЮЧЕНИЕ ТОЧНОГО GPS (Только если Авто ВКЛ)
# ==========================================
- id: turn_on_high_accuracy_at_zone
alias: "gps|turn_on_at_home_high_zone"
trigger:
- platform: zone
entity_id: device_tracker.cph2573_2
zone: zone.gps_home_high
event: enter
- platform: state
entity_id: input_boolean.intercom_auto_open
to: "on"
condition:
- condition: state
entity_id: input_boolean.intercom_auto_open
state: "on"
- condition: zone
entity_id: device_tracker.cph2573_2
zone: zone.gps_home_high
- condition: template
value_template: "{{ not is_state('binary_sensor.oneplus12_high_accuracy_mode', 'on') }}"
action:
- service: notify.mobile_app_oneplus12
data:
message: "command_high_accuracy_mode"
data:
command: "turn_on"
ttl: 0
priority: high
# ==========================================
# 3. АВТООТКРЫТИЕ ДВЕРИ (Тройное с кнопками)
# ==========================================
- id: auto_open_at_intercom_zone
alias: "intercom|open_at_zone"
trigger:
- platform: zone
entity_id: device_tracker.cph2573_2
zone: zone.intercom
event: enter
condition:
- 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:
count: 7
sequence:
- service: shell_command.open_goodline_door
# Ждем 7 секунд перед следующим открытием (кроме последнего раза)
- condition: template
value_template: "{{ repeat.index < 3 }}"
- delay:
seconds: 5
# Уведомление с кнопками управления
- service: telegram_bot.send_message
data:
target: -1002006010424
parse_mode: html
message: "🏠 <b>Зона INTERCOM достигнута!</b>\nДверь открыта 3 раза с интервалом 7 сек."
inline_keyboard:
- "🔔 Домофон:/intercom_menu"
- "🏠 Главное меню:/menu_back"
# Выключение точного GPS для экономии заряда
- service: notify.mobile_app_oneplus12
data:
message: "command_high_accuracy_mode"
data:
command: "turn_off"
ttl: 0
priority: high
# ==========================================
# 4. ВЫКЛЮЧЕНИЕ GPS ПРИ ВЫХОДЕ (Работает ВСЕГДА для экономии заряда)
# ==========================================
- id: turn_off_high_accuracy_on_leave
alias: "gps|turn_off_on_leave"
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: notify.mobile_app_oneplus12
data:
message: "command_high_accuracy_mode"
data:
command: "turn_off"
ttl: 0
priority: high