Frigate notifications on telegram with picture

Hi,
I have Frigate and telegram installed with a Camera R4252.
I try to create an automation to notify when something it’s triggered on the camera.
My camera have those sensors :


My automation :

alias: Alarm
description: Alarme
trigger:
  - platform: state
    entity_id:
      - binary_sensor.detecteur_ouverture_porte_baie_vitree_contact
    from: "off"
    to: "on"
  - platform: state
    entity_id:
      - sensor.r4252_smart_outdoor_camera_cat_count
    from: "0"
    to: "1"
condition:
  - condition: state
    entity_id: input_boolean.alarm_override
    state: "on"
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: sensor.r4252_smart_outdoor_camera_cat_count
            state: "1"
        sequence:
          - service: notify.lilp_bot
            metadata: {}
            data:
              message: Un chat a été détecté
              title: Alarm Chat
mode: single

The entity image.r4252_smart_outdoor_camera_cat who can see as 4 entity on picture have those attributes :

access_token: XxX
entity_picture: >-
  /api/image_proxy/image.r4252_smart_outdoor_camera_cat?token=XxX
friendly_name: R4252 Smart Outdoor Camera Cat

The notification is trigged well when the cat entity count change from 0 to 1, and send a message.
But I wish add picture or snapshot of the trigged.
I try to add it by using :

entity_picture: >-
/api/image_proxy/image.r4252_smart_outdoor_camera_cat?token=XxX

But don’t know how to.

Thanks.

For this it’s recommended to use the frigate notification blueprint

@crzynik the Frigate notification blueprint does not support Telegram AFAIK:

And there is not much movement on the pull requests (last in February 2024):

Is a good one to look at as well

Yes Frigate Notification Blueprint doesn’t support Telegram notification.
Also, I wish add more sensor than frigate. Like my windows sensor and Frigate Notification blueprint don’t allow that.

In Home Assistant 2024.7 you will be able to convert blueprint into an editable automation. You can then replace the notification with Frigate:

It will be a nice new feature.
Still in 2024.6, I’m waiting the official 2024.7 so. :slight_smile:

It should be released today after the release party:

For now, I’m testing a solution like.
3 frigate automations (night, home, away)


With another automations to enable theses by times :

alias: Activation auto alarme nuit
description: Activation auto alarme nuit
trigger:
  - platform: time
    at: "00:00:00"
  - platform: time
    at: "06:00:00"
condition:
  - condition: state
    entity_id: automation.frigate_away
    state: "off"
  - condition: state
    entity_id: automation.frigate_notifications
    state: "off"
    enabled: false
action:
  - choose:
      - conditions:
          - condition: time
            after: "12:00:00"
            before: "06:00:00"
        sequence:
          - service: automation.toggle
            metadata: {}
            data: {}
            target:
              entity_id:
                - automation.frigate_night
                - automation.frigate_notifications
      - conditions:
          - condition: time
            after: "06:00:00"
            before: "12:00:00"
        sequence:
          - service: automation.toggle
            metadata: {}
            data: {}
            target:
              entity_id:
                - automation.frigate_night
                - automation.frigate_notifications
mode: single

And another for better away mode with windows sensor

alias: Alarm
description: Alarme
trigger:
  - platform: state
    entity_id:
      - binary_sensor.detecteur_ouverture_porte_baie_vitree_contact
    from: "off"
    to: "on"
condition:
  - condition: state
    entity_id: automation.frigate_away
    state: "on"
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: sensor.r4252_smart_outdoor_camera_cat_count
            state: "1"
        sequence:
          - service: notify.lilp_bot
            metadata: {}
            data:
              message: Un chat a été détecté
              title: Alarm Chat
            enabled: false
          - service: notify.mobile_app_oneplus
            metadata: {}
            data:
              message: Un chat a été détecté dehors
      - conditions:
          - condition: state
            entity_id: sensor.r4252_smart_outdoor_camera_dog_count
            state: "1"
        sequence:
          - service: notify.lilp_bot
            metadata: {}
            data:
              message: Un chien a été détecté
              title: Alarm Chien
            enabled: false
          - service: notify.mobile_app_oneplus
            metadata: {}
            data:
              message: Un chien a été détecté dehors
      - conditions:
          - condition: state
            entity_id: sensor.r4252_smart_outdoor_camera_person_count
            state: "1"
        sequence:
          - service: notify.lilp_bot
            metadata: {}
            data:
              message: Une personne a été détecté
              title: Alarm Personn
            enabled: false
          - service: notify.mobile_app_oneplus
            metadata: {}
            data:
              message: Une personne a été détecté dehors

It seems you are using the same services to get notified. You should use a script to do so, it will make your automation more readable and then you can adapt your notifications there.

I have this script:

alias: Notify People in the building
sequence:
  - parallel:
      - service: notify.telegramcloom
        data:
          title: "*{{ title }}*"
          message: |
            ```b {{ message }}```
      - service: notify.persistent_notification
        data:
          title: "{{ title }}"
          message: |
            {{ message }}
      - service: notify.cloomwhatsapp
        data:
          message: |
            *{{ title }}*
            {{ message }}
        enabled: false
      - service: notify.anaconciergewhatsapp
        data:
          message: |
            *{{ title }}*
            {{ message }}
        enabled: false
      - service: notify.mobile_app_rs_403
        data:
          title: "{{ title }}"
          message: "{{ message }}"
        enabled: true
mode: single
icon: mdi:message-badge-outline

There are some disabled because Whatsapp messages are not free anymore. You can use come up with something if you don’t want to notify all the services in your script.

Then I call this script from automations:

service: script.notify_sbs_lofts
data:
  title: "Problem detected on {{ trigger.from_state.attributes.friendly_name }}"
  message: >
    {{"\n"}}ECS: {{ states('sensor.sonde_ecs') }} {{"\n"}}Retour coge circuit
    chauffage: {{ states('sensor.sonde_retour_coge_circuit_chauffage') }}
    {{"\n"}}Retour Cogénération: {{ states('sensor.retour_cogeneration') }}
    {{"\n"}}Cogénération en défaut: {{ "YES!!!" if
    states('binary_sensor.i7_default_coge') == "on" else "NO" }}

Don’t really understand your tips.
I create a script

alias: Notify
sequence:
  - parallel:
      - service: notify.lilp_bot
        data:
          title: "*{{ title }}*"
          message: |
            ```b {{ message }}```
      - service: notify.mobile_app_oneplus
        data:
          title: "{{ title }}"
          message: |
            {{ message }}
mode: single
icon: mdi:message-badge-outline

Then an automation :

alias: Test notification
description: ""
trigger: []
condition: []
action:
  - service: script.test
    metadata: {}
    data:
      title: Problem detected on {{ trigger.from_state.attributes.friendly_name }}
      message: >
        {{"\n"}}ECS: {{ states('sensor.sonde_ecs') }} {{"\n"}}Retour coge
        circuit chauffage: {{
        states('sensor.sonde_retour_coge_circuit_chauffage') }} {{"\n"}}Retour
        Cogénération: {{ states('sensor.retour_cogeneration') }}
        {{"\n"}}Cogénération en défaut: {{ "YES!!!" if
        states('binary_sensor.i7_default_coge') == "on" else "NO" }}
mode: single

But when I run the automation nothing happen.

It’s normal, you re-used my sensors in the message.

Create a script that is taking 2 arguments: title and message

alias: Notify
sequence:
  - parallel:
      - service: notify.lilp_bot
        data:
          title: "{{ title }}"
          message: "{{ message }}"
      - service: notify.mobile_app_oneplus
        data:
          title: "{{ title }}"
          message: "{{ message }}"
mode: single
icon: mdi:message-badge-outline

[/quote]

Then you can use the developer tools and call the script:

service: script.notify_script_name
data: 
  title: "Test"
  message: "Ne rien faire"

Then if you have a sensor living_room_temperature you can put it in the message:

service: script.notify_script_name
data: 
  title: "Too Hot!"
  message: "Living room is burning hot, temperature is {{ states('sensor.living_room_temperature') }} degrees!"

For automation templates you can look at the official documentation:

I make the changes
Script

alias: Notify
sequence:
  - parallel:
      - service: notify.lilp_bot
        data:
          title: "*{{ title }}*"
          message: |
            ```b {{ message }}```
      - service: notify.mobile_app_oneplus
        data:
          title: "{{ title }}"
          message: |
            {{ message }}
mode: single
icon: mdi:message-badge-outline
description: Script Notify

The automation

alias: Alarm
description: Alarme
trigger:
  - platform: state
    entity_id:
      - binary_sensor.detecteur_ouverture_porte_baie_vitree_contact
    from: "off"
    to: "on"
condition:
  - condition: state
    entity_id: automation.frigate_away
    state: "on"
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: sensor.r4252_smart_outdoor_camera_cat_count
            state: "1"
        sequence:
          - service: script.notify
            data:
              title: Mouvement détecté
              message: >
                {{"\n"}}Mouvement détecté: {{
                states('sensor.r4252_smart_outdoor_camera_cat_count') }}
                personne détectée.
      - conditions:
          - condition: state
            entity_id: sensor.r4252_smart_outdoor_camera_dog_count
            state: "1"
        sequence:
          - service: script.notify
            data:
              title: Mouvement détecté
              message: >
                {{"\n"}}Mouvement détecté: {{
                states('sensor.r4252_smart_outdoor_camera_cat_count') }}
                personne détectée.
      - conditions:
          - condition: state
            entity_id: sensor.r4252_smart_outdoor_camera_person_count
            state: "1"
        sequence:
          - service: script.test
            metadata: {}
            data:
              title: Mouvement détecté
              message: >
                {{"\n"}}Mouvement détecté: {{
                states('sensor.r4252_smart_outdoor_camera_cat_count') }}
                personne détectée.
          - service: script.notify
            data:
              title: Mouvement détecté
              message: >
                {{"\n"}}Mouvement détecté: {{
                states('sensor.r4252_smart_outdoor_camera_cat_count') }}
                personne détectée.