DieMetRik

Frigate MQTT Оповещение в Telegram с камер (v4)

Jun 26th, 2025 (edited)
801
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 6.33 KB | None | 0 0
  1. alias: Frigate MQTT Оповещение в Telegram с камер
  2. description: ""
  3. triggers:
  4.   - topic: frigate/events
  5.     enabled: true
  6.     alias: Получено сообщение от MQTT Frigate\Event
  7.     trigger: mqtt
  8.   - alias: Получено сообщение от MQTT Frigate\Event
  9.     topic: test/events
  10.     enabled: true
  11.     trigger: mqtt
  12. conditions: []
  13. actions:
  14.   - variables:
  15.       type: "{{ trigger.payload_json['type'] }}"
  16.       camera: "{{ trigger.payload_json['after']['camera'] }}"
  17.       id: "{{ trigger.payload_json['after']['id'] }}"
  18.       label: "{{ trigger.payload_json['after']['label'] }}"
  19.       score: "{{ (trigger.payload_json['after']['score'] | float(0) * 100) | int(0) }}"
  20.       area: "{{ trigger.payload_json['after']['area'] }}"
  21.       datetime: >-
  22.         {{ trigger.payload_json['after']['frame_time'] |
  23.        timestamp_custom('%Y-%m-%d %H:%M:%S') }}
  24.       label_rus: |
  25.        {% set object_name = { "cat":
  26.           "кот", "dog": "собака", "person": "человек", "car": "машина" } %}{% set
  27.           object = label %}[{% for key in
  28.           object_name.keys() %}{% if key==object %}{{object_name[key]}}{% endif %}{%
  29.           endfor %}]
  30.       target: -100XXXXXXXXXX
  31.       ip_base_url: http://192.168.1.130:8123/api/frigate/notifications/
  32.       domain_base_url: https://domain.ru/api/frigate/notifications/
  33.       disable_notification_sp: false
  34.       label_disable_notification: ""
  35.       indoor_camera1: livingroom
  36.       indoor_camera2: kitchen
  37.       indoor_camera3: hall
  38.       outdoor_camera1: entrance
  39.     alias: Определение переменных
  40.   - alias: Проверочное сообщение, если нужно проверить ПЕРЕМЕННЫЕ
  41.     action: telegram_bot.send_message
  42.     metadata: {}
  43.     data:
  44.       disable_notification: true
  45.       message: |-
  46.         MQTT frigate event:
  47.         <pre>camera: "{{ camera }}"
  48.         id: "{{ id }}"
  49.         area: "{{area}}"
  50.         label: "{{ label }}"
  51.         label_rus: "{{label_rus}}"
  52.         score: "{{ score }}"
  53.         type: "{{ type }}"
  54.         datetime: "{{ datetime }}"
  55.         </pre>
  56.         УСТАНОВОЧНЫЕ:
  57.         <pre>ip_base_url: "{{ ip_base_url }}"
  58.         domain_base_url: "{{ domain_base_url }}"
  59.         disable_notification_sp: "{{ disable_notification_sp }}"
  60.         label_disable_notification: "{{ label_disable_notification }}"
  61.         target: "{{ target }}"
  62.         </pre>
  63.       parse_mode: html
  64.     enabled: false
  65.   - alias: Камеры в помещении (Только New и End)
  66.     if:
  67.       - alias: Если != update
  68.         condition: template
  69.         value_template: "{{ type != 'update' }}"
  70.         enabled: true
  71.       - condition: not
  72.         conditions:
  73.           - condition: state
  74.             entity_id: alarm_control_panel.alarm_home
  75.             state: disarmed
  76.         alias: Если НЕ Снято с охраны
  77.         enabled: true
  78.       - alias: ЕСЛИ любая камера в доме сработала
  79.         condition: or
  80.         conditions:
  81.           - condition: template
  82.             value_template: "{{ camera == indoor_camera1 }}"
  83.             enabled: true
  84.           - condition: template
  85.             value_template: "{{ camera == indoor_camera2 }}"
  86.             enabled: true
  87.           - condition: template
  88.             value_template: "{{ camera == indoor_camera3 }}"
  89.             enabled: true
  90.         enabled: true
  91.       - condition: or
  92.         conditions:
  93.           - condition: state
  94.             entity_id: vacuum.roborock_s5_max
  95.             state: docked
  96.           - condition: state
  97.             entity_id: vacuum.roborock_s5_max
  98.             state: idle
  99.           - condition: state
  100.             entity_id: vacuum.roborock_s5_max
  101.             state: unavailable
  102.           - condition: state
  103.             entity_id: vacuum.roborock_s5_max
  104.             state: error
  105.         alias: Если пылесос не убирается
  106.         enabled: true
  107.     then:
  108.       - metadata: {}
  109.         data:
  110.           parse_mode: html
  111.           target: "{{ target }}"
  112.           disable_notification: "{{ disable_notification_sp }}"
  113.           url: "{{ip_base_url+id}}/snapshot.jpg?bbox=1&motion=1&regions=1"
  114.           inline_keyboard: |
  115.            🎥:/send_video {{id}} {{camera}},📴:/disarm_alarm
  116.           caption: >-
  117.             Камера: [ <a href='{{domain_base_url+id}}/clip.mp4'>{{camera}} </a>
  118.            ] {{label_disable_notification}}
  119.  
  120.             <pre>Тип: {{type}} {{ label_rus }} {{area}}/{{score}}%  
  121.  
  122.             id: {{id}}
  123.  
  124.             Дата: {{datetime}}</pre>
  125.         action: telegram_bot.send_photo
  126.     enabled: true
  127.   - alias: Камера entrance (Смотрит в подъезд)
  128.     if:
  129.       - alias: "==entrance"
  130.         condition: template
  131.         value_template: "{{ camera == outdoor_camera1 }}"
  132.         enabled: true
  133.     then:
  134.       - alias: Определяем disable_notification
  135.         if:
  136.           - condition: or
  137.             conditions:
  138.               - condition: template
  139.                 value_template: |
  140.                  {{ is_state('input_boolean.mute_telegram', 'on') }}
  141.                 alias: mute_telegram IS on
  142.               - alias: Если == update
  143.                 condition: template
  144.                 value_template: "{{ type == 'update' }}"
  145.                 enabled: true
  146.               - alias: area < 20000
  147.                 condition: template
  148.                 value_template: "{{ area < 20000 }}"
  149.         then:
  150.           - variables:
  151.               disable_notification_sp: true
  152.               label_disable_notification: (m)
  153.       - metadata: {}
  154.         data:
  155.           parse_mode: html
  156.           target: "{{ target }}"
  157.           disable_notification: "{{ disable_notification_sp }}"
  158.           url: "{{ip_base_url+id}}/snapshot.jpg?bbox=1&motion=1&regions=1"
  159.           inline_keyboard: |
  160.            🎥:/send_video {{id}} {{camera}},📴:/disarm_alarm
  161.           caption: >-
  162.             Камера: [ <a href='{{domain_base_url+id}}/clip.mp4'>{{camera}} </a>
  163.            ] {{label_disable_notification}}
  164.  
  165.             <pre>Тип: {{type}} {{ label_rus }} {{area}}/{{score}}%  
  166.  
  167.             id: {{id}}
  168.  
  169.             Дата: {{datetime}}</pre>
  170.         action: telegram_bot.send_photo
  171. trace:
  172.   stored_traces: 50
  173. mode: queued
  174. max: 20
  175.  
Advertisement
Add Comment
Please, Sign In to add comment