Automation to send telegram message on any state change

I’m trying to set up an automation to send out a message any time there is a state change to an entity, but it doesn’t seem to work. This syntax passes the configuration checker, but never seems to be triggered. My Telegram integration works with an automation that sends a message when HA starts and stops, so I believe that the integration is at least fine.

Does anyone have any suggestions?

- alias: Device Status Detection
  hide_entity: false
  trigger:
  - platform: state
    entity_id:
      - zha.king_of_fans_inc_hdc52eastwindfan
      - zha.ledvance_br30_rgbw
      - zha.ledvance_br30_rgbw_2
      - zha.ledvance_br30_rgbw_3
      - zha.ledvance_br30_rgbw_4
      - zha.lumi_lumi_sensor_wleak_aq1_2
      - zha.lumi_lumi_sensor_wleak_aq1
      - zha.lumi_lumi_vibration_aq1
      - zha.lumi_lumi_weather
      - zha.lumi_lumi_weather_2
      - zha.lumi_lumi_weather_3
      - zha.osram_lightify_gardenspot_rgb
      - zha.osram_lightify_par38_on_off_dim
      - zha.osram_lightify_par38_on_off_dim_2
      - zha.philips_lct016
      - zha.philips_lct016_2
      - zha.sengled_z01_a19nae26
      - zha.zha_waxman_leaksmart_water_sensor_v2_00128dd1
  action:
  - data:
      message: "{{ trigger.to_state.attributes.friendly_name }} changed state."
      title: '*Home Assistant*'
    service: notify.notify_telegram

1 - is the automation switched on?
2 - you need data_template in your action.
3 - using stars in the title might be causing an error depending on the parse_mode you’ve set for your telegram notifier.

1 Like

Yes, all the automations are on.

So,

  action:
    service: notify.notify_telegram
    data_template:
      title: '*Home Assistant*'
      message: "{{ trigger.to_state.attributes.friendly_name }} changed state."

I use the * in other Telegram messages.

Turns out it was the data_template, thanks!

1 Like

This doesn’t seem to be working on latest versions of HA…

FWIW I’m running 0.95.4 and the Telegram integration still seems to work fine.

1 Like