Notify.notify not working with trigger id

Hi,
I am trying to get a message showing when there is a change of state from off to on, meaning the window is open. I want to get a notification with the name of the window. I have searched through this forum, and have tried different lines, still does not work. Automation shows as triggered, but I do not any kind of notification. Other automations with simple messages work fine. I tried the way it is below, I tried {{ trigger.name }} and {{ trigger.entity_id }}.

- id: '1596119039079'
  alias: TEST window is open
  description: ''
  trigger:
  - entity_id: binary_sensor.living_room_window_sensor
    from: 'off'
    platform: state
    to: 'on'
  - entity_id: binary_sensor.bedroom_window_sensor
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      message: Window {{ trigger.to_state.attributes.friendly_name }} is open
    service: notify.notify
  mode: single

Thank you.

1 Like

Rule 1.

… and Use Templates to Determine the Attributes in a service call.

It is in quotes, tried it with single, double, no quotes. Does not work.

Rule 1 is this one:

image

What did you see at that link?!

I think you skipped right over Rule 1. :laughing:

EDIT: Sorry, we’re not picking on you. We just have too much time on our hands! :stuck_out_tongue_winking_eye: This is actually a very common mistake for people new to HA automations.

First, you can combine your trigger into one trigger, because you check both for the same state change.
Second, you need to use data_template instead of data as @Troon pointed out.

Try like this:

- id: '1596119039079'
  alias: TEST window is open
  description: ''
  trigger:
  - entity_id: binary_sensor.living_room_window_sensor, binary_sensor.bedroom_window_sensor
    from: 'off'
    platform: state
    to: 'on'
  action:
  - data_template:
      message: Window {{ trigger.to_state.attributes.friendly_name }} is open
    service: notify.notify


I thought this referred to rule number 3 xD thank you it is fixed now.

1 Like

Its okay, I appreciate the help!

That’s just how many people pressed the link :slight_smile:

would you be so kind to mark the post that helped you find the solution as the solution? This way other people who might have the same problem will immediately see the solution, instead of scrolling through all replies.

Yes, I figured it out. Sorry.

I did, is it not showing you?

It is, I was probably replying before I reloaded the page, sorry for the confusion.

thanks for this post, it fixed my problem but, I used to have
service: notify.mobile_app_iphone and worked fine setting it up with automation from Hassio and not messing with the config file. i don’t know what is the difference between notify.notify and that. plus this should be easy to set up notification from automation but that doesn’t work anymore!!

I have been trying data_template, with single quotes, doble…i can not refer any trigger.id in my messages.

Tried different services; notify, telegram_bot.send_message, ha notifies…

Can you help me?

Not without seeing some (properly-formatted) code, and knowing what version you’re running.