Telegram notification data_template

Hi there, I am trying to create an automation to notify the start of irrigation

- alias: 'Sprinkler notification'
  trigger:
  - platform: state
    entity_id: 
      - switch.zone_4
      - switch.zone_3
      - switch.zone_2
      - switch.zone_1
    to: 'on'
  action:
    service: notify.home
    data_template: 
       message: '{{ trigger.entity_id }}'

unfortunately it works with

 data: 
       message: "Sprinkler on"

but it doesn’t work with data_template to select an entity_id.
thanks in advance

Try this:

{{ trigger.to_state.entity_id }}

I have tried without success

- alias: 'Sprinkler notification'
  trigger:
  - platform: state
    entity_id: 
      - switch.zona_4
      - switch.zona_3
      - switch.zona_2
      - switch.zona_1
    to: 'on'
  action:
    service: notify.home
    data_template: 
       message: '{{ trigger.to_state.entity_id }}'

any other suggestions?

What message do you get or do you get no message at all?

I noticed once it was switch.zone_1 and now it’s switch.zona_1, please make sure that it’s the correct entity id

No message at all.
Entity is correct, zone was a previous version

Thanks

What kind of notifier is notify.home?
Do you get a notification if you change the action to:

service: persistent_notification.create
data_template: 
  message: '{{ trigger.to_state.entity_id }}'

This work.

“notify.home” sends a telegram message, but I can’t understand why it shouldn’t work, I already use “notify.home” for other notifications that work properly

I did a test with another automation and {{trigger.entity_id}} does not work with notification via Telegram but works correctly with persistent_notification.create.
Probably some Telegram bot setting?

is this notify.home a notification group or just one notifier?

SOLVED

Fixed, the problem was Telegram. I changed the service and set the parse_mode: html

- alias: 'Sprinkler notification'
  trigger:
  - platform: state
    entity_id: 
      - switch.zona_4
      - switch.zona_3
      - switch.zona_2
      - switch.zona_1
    to: 'on'
  action:
  - service: telegram_bot.send_message
    data_template: 
       target: YOUR CHAT ID
       parse_mode: html
       message: "Sprinkler on in zone {{ trigger.to_state.entity_id.split('_')[1] }}"

thank you very much

3 Likes