πŸ“’ Notifications & Announcements

FAQ - How can I set what triggered the notification in the message.

You may have multiple entities used for your trigger as it help reduce down the amount of automation you have but you still would like to customize the message so you know what happened. They could be;

  • Sensors that keep going unavailable
  • Water leak sensors
  • Plants moisture sensors
  • Etc

Lets look at how we can report what happened.

We will use this code in our message. It will report the friendly name of the entity in your message that triggered the automation.

{{ states[trigger.entity_id].attributes.friendly_name }}

This is how it would look in your message.

If you’re using a Numeric State to trigger the automation and want to see the exact value that triggered it, use the following code.

{{ trigger.to_state.state }}

To display both what triggered the automation and the numeric value at the time, set it up as shown in the code below.

{{ states[trigger.entity_id].attributes.friendly_name }} triggered with a value of {{ trigger.to_state.state }}

This setup lets you know what triggered the automation and, if the trigger is a numeric state, the value that caused it. You can use this in any message, making it compatible with your UI or Text-to-Speech notifications as well.

Time & Date

# This give you time 12 hr format
{{ now().strftime('%I:%M:%S %p').lstrip('0') }}

# This give you time 24 hr format
{{ now().strftime('%H:%M:%S') }}

# This gives you date - change year, month and day to suit you.
{{ now().strftime('%Y-%m-%d') }}

Enjoy

Blacky :smiley:

Back to FAQ: Click Here

1 Like