Advertisement
DieMetRik

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

Jun 26th, 2025
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 5.49 KB | None | 0 0
  1. description: ""
  2. mode: queued
  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: "-100XXXXXXXXX"
  31.       ip_base_url: http://192.168.XXX.XXX: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.       - alias: ЕСЛИ любая камера в доме сработала
  72.         condition: or
  73.         conditions:
  74.           - condition: template
  75.             value_template: "{{ camera == indoor_camera1 }}"
  76.             enabled: true
  77.           - condition: template
  78.             value_template: "{{ camera == indoor_camera2 }}"
  79.             enabled: true
  80.           - condition: template
  81.             value_template: "{{ camera == indoor_camera3 }}"
  82.             enabled: true
  83.         enabled: true
  84.     then:
  85.       - metadata: {}
  86.         data:
  87.           parse_mode: html
  88.           target: "{{ target }}"
  89.           disable_notification: "{{ disable_notification_sp }}"
  90.           url: "{{ip_base_url+id}}/snapshot.jpg?bbox=1&motion=1&regions=1"
  91.           inline_keyboard: |
  92.            🎥:/send_video {{id}} {{camera}},📴:/disarm_alarm
  93.           caption: >-
  94.             Камера: [ <a href='{{domain_base_url+id}}/clip.mp4'>{{camera}} </a>
  95.            ] {{label_disable_notification}}
  96.  
  97.             <pre>Тип: {{type}} {{ label_rus }} {{area}}/{{score}}%  
  98.  
  99.             id: {{id}}
  100.  
  101.             Дата: {{datetime}}</pre>
  102.         action: telegram_bot.send_photo
  103.     enabled: true
  104.   - alias: Камера entrance (Смотрит в подъезд)
  105.     if:
  106.       - alias: "==entrance"
  107.         condition: template
  108.         value_template: "{{ camera == outdoor_camera1 }}"
  109.         enabled: true
  110.     then:
  111.       - alias: Определяем disable_notification
  112.         if:
  113.           - condition: or
  114.             conditions:
  115.               - condition: template
  116.                 value_template: |
  117.                  {{ is_state('input_boolean.mute_telegram', 'on') }}
  118.                 alias: mute_telegram IS on
  119.               - alias: Если == update
  120.                 condition: template
  121.                 value_template: "{{ type == 'update' }}"
  122.                 enabled: true
  123.               - alias: area < 20000
  124.                 condition: template
  125.                 value_template: "{{ area < 20000 }}"
  126.         then:
  127.           - variables:
  128.               disable_notification_sp: true
  129.               label_disable_notification: (m)
  130.       - metadata: {}
  131.         data:
  132.           parse_mode: html
  133.           target: "{{ target }}"
  134.           disable_notification: "{{ disable_notification_sp }}"
  135.           url: "{{ip_base_url+id}}/snapshot.jpg?bbox=1&motion=1&regions=1"
  136.           inline_keyboard: |
  137.            🎥:/send_video {{id}} {{camera}},📴:/disarm_alarm
  138.           caption: >-
  139.             Камера: [ <a href='{{domain_base_url+id}}/clip.mp4'>{{camera}} </a>
  140.            ] {{label_disable_notification}}
  141.  
  142.             <pre>Тип: {{type}} {{ label_rus }} {{area}}/{{score}}%  
  143.  
  144.             id: {{id}}
  145.  
  146.             Дата: {{datetime}}</pre>
  147.         action: telegram_bot.send_photo
  148. trace:
  149.   stored_traces: 50
  150. max: 20
  151.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement