Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alias: Frigate. Пересечение зон
- description: ""
- triggers:
- - topic: frigate/events
- trigger: mqtt
- - topic: test/events
- trigger: mqtt
- conditions: []
- actions:
- - variables:
- entrance_camera_name: entrance
- alias: Определение УСТАНОВОЧНЫХ переменных для условий
- - variables:
- after_zones: "{{ trigger.payload_json['after']['entered_zones'] }}"
- before_zones: "{{ trigger.payload_json['before']['entered_zones'] }}"
- camera: "{{ trigger.payload_json['after']['camera'] }}"
- id: "{{ trigger.payload_json['after']['id'] }}"
- label: "{{ trigger.payload_json['after']['label'] }}"
- score: "{{ trigger.payload_json['after']['score'] }}"
- type: "{{ trigger.payload_json['type'] }}"
- datetime: >-
- {{ trigger.payload_json['after']['frame_time'] |
- timestamp_custom('%Y-%m-%d %H:%M:%S') }}
- alias: Определение переменных из MQTT frigate events
- - alias: Проверочное сообщние, если нужно проверить ПЕРЕМЕННЫЕ
- action: telegram_bot.send_message
- metadata: {}
- data:
- disable_notification: true
- message: |-
- MQTT frigate event:
- <pre>after_zones: "{{ after_zones }}"
- before_zones: "{{ before_zones }}"
- camera: "{{ camera }}"
- id: "{{ id }}"
- label: "{{ label }}"
- score: "{{ score }}"
- type: "{{ type }}"
- </pre>
- УСТАНОВОЧНЫЕ:
- <pre>camera_name = "{{ camera_name }}"
- zone_name_out: "{{ zone_name_out }}"
- zone_name_in: "{{ zone_name_in }}"
- </pre>
- parse_mode: html
- enabled: false
- - alias: >-
- Сравниваем название камеры прилетевшее с frigate event с УСТАНОВОЧНЫМ
- значением.
- if:
- - condition: template
- value_template: "{{ type == \"update\" }}"
- alias: type == update
- - condition: template
- value_template: "{{ before_zones != after_zones}}"
- alias: before_zones != after_zones
- - condition: template
- value_template: "{{ after_zones | length > 1 }}"
- alias: Если длинна массива after_zones[...] > 1
- then:
- - variables:
- max_arr: "{{ after_zones | length - 1 }}"
- zone_out: "{{ after_zones[max_arr - 1] }}"
- zone_in: "{{ after_zones[max_arr] }}"
- - alias: >-
- Если название камеры = установочной (для каждоый камеры нужны свои
- зоны)
- if:
- - alias: camera == camera_name
- condition: template
- value_template: "{{ camera == entrance_camera_name }}"
- then:
- - action: telegram_bot.send_photo
- metadata: {}
- data:
- parse_mode: html
- authentication: digest
- url: >-
- http://192.168.1.130:8123/api/frigate/notifications/{{id}}/snapshot.jpg?bbox=1&motion=1®ions=1
- caption: |-
- Перемещение
- <u> {{ zone_out }} </u> --> <u>{{ zone_in }}</u>
- <pre>{{ datetime }}"
- id:{{ id }}</pre>
- enabled: true
- enabled: true
- - alias: >-
- Сравниваем название камеры прилетевшее с frigate event с УСТАНОВОЧНЫМ
- значением.
- if:
- - condition: template
- value_template: "{{ type == \"update\" }}"
- alias: type == update
- - condition: template
- value_template: "{{ before_zones != after_zones}}"
- alias: before_zones != after_zones
- - condition: template
- value_template: "{{ after_zones | length > 1 }}"
- alias: Если длинна массива after_zones[...] > 1
- then:
- - variables:
- max_arr: "{{ after_zones | length - 1 }}"
- zone_out: "{{ after_zones[max_arr - 1] }}"
- zone_in: "{{ after_zones[max_arr] }}"
- - alias: >-
- Если название камеры = установочной (для каждоый камеры нужны свои
- зоны)
- if:
- - condition: or
- conditions:
- - condition: and
- conditions:
- - alias: camera == camera_name
- condition: template
- value_template: "{{ camera == entrance_camera_name }}"
- - condition: and
- conditions:
- - condition: template
- value_template: "{{ zone_out == entrance_zone_name_out }}"
- - condition: template
- value_template: "{{ zone_in == entrance_zone_name_in }}"
- alias: Камера 1 (entrance)
- - alias: Камера 2 (livingroom)
- condition: and
- conditions:
- - alias: camera == camera_name
- condition: template
- value_template: "{{ camera == livingroom_camera_name }}"
- - condition: and
- conditions:
- - condition: template
- value_template: "{{ zone_out == livingroom_zone_name_out }}"
- - condition: template
- value_template: "{{ zone_in == livingroom_zone_name_in }}"
- then:
- - action: telegram_bot.send_message
- metadata: {}
- data:
- disable_notification: true
- message: |-
- <pre>
- datetime: "{{datetime}}"
- zone_out: "{{ zone_out }}"
- entrance_zone_name_out: "{{ entrance_zone_name_out }}"
- zone_in: "{{ zone_in }}"
- entrance_zone_name_out: "{{ entrance_zone_name_in}}"
- </pre>
- parse_mode: html
- alias: ПРОВЕРОЧНОЕ сообщение
- enabled: false
- - action: telegram_bot.send_photo
- metadata: {}
- data:
- parse_mode: html
- authentication: digest
- url: >-
- http://192.168.1.130:8123/api/frigate/notifications/{{id}}/snapshot.jpg?bbox=1&motion=1®ions=1
- caption: |-
- Перемещение
- <u> {{ zone_out }} </u> --> <u>{{ zone_in }}</u>
- <pre>{{ datetime }}"
- id:{{ id }}</pre>
- enabled: true
- enabled: false
- mode: single
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement