---
- id: notify_on_device_offline
  alias: Notify when a device goes offline
  mode: parallel
  trigger:
    - platform: state
      entity_id:
        - button.hdipc_reboot
        - camera.hdipc_mainstream
        - device_tracker.cam_1
      to: "unavailable"
      for:
        minutes: 5
  action:
    - service: telegram_bot.send_message
      data:
        message: >-
          {{ state_attr(trigger.to_state.entity_id, 'friendly_name') }} is offline since 5 minutes or more.
        title: "A device is offline!"

- id: frigate_event_notify
  alias: Notify on Frigate events
  description: "Notify when a Frigate event occurs"
  trigger:
    - platform: mqtt
      topic: frigate/events
  action:
    - service: telegram_bot.send_photo
      data:
        url: >-
          http://raspberrypi2.edge.lab.ferrari.how:5000/api/events/{{trigger.payload_json["after"]["id"]}}/snapshot.jpg
        caption: >-
          A {{trigger.payload_json["after"]["label"]}} was detected.
        message_tag: >-
          {{trigger.payload_json["after"]["id"]}}
  mode: queued
...

---
- id: notify_on_device_offline
  alias: Notify when a device goes offline
  mode: parallel
  trigger:
    - platform: state
      entity_id:
        - button.hdipc_reboot
        - camera.hdipc_mainstream
        - device_tracker.cam_1
      to: "unavailable"
      for:
        minutes: 5
  action:
    - service: telegram_bot.send_message
      data:
        message: >-
          {{ state_attr(trigger.to_state.entity_id, 'friendly_name') }} is offline since 5 minutes or more.
        title: "A device is offline!"

- id: frigate_event_notify
  alias: Notify on Frigate events
  description: "Notify when a Frigate event occurs"
  trigger:
    - platform: mqtt
      topic: frigate/events
  action:
    - service: telegram_bot.send_photo
      data:
        url: >-
          http://raspberrypi2.edge.lab.ferrari.how:5000/api/events/{{trigger.payload_json["after"]["id"]}}/snapshot.jpg
        caption: >-
          A {{trigger.payload_json["after"]["label"]}} was detected. Here is a snapshot of the event.
        message_tag: >-
          {{trigger.payload_json["after"]["id"]}}
    - service: telegram_bot.send_video
      data:
        url: >-
          http://raspberrypi2.edge.lab.ferrari.how:5000/api/events/{{trigger.payload_json["after"]["id"]}}/clip.mp4
        caption: >-
          A {{trigger.payload_json["after"]["label"]}} was detected. Here is a recording of the event.
        message_tag: >-
          {{trigger.payload_json["after"]["id"]}}
  mode: queued
...

Configure telegram bot to also send recordings
Configure telegram bot to also send recordings
