Notification Setup Help

Hi All,

Need some guidance to get a notification when a couple of sensors goes NaN.

Here is what I have figured out this far (I think):

- id: Create a notification when devices goes NaN
  alias: Create a notification when devices goes NAN
  trigger:
    platform: state
    entity_id: sensor.1
    entity_id: sensor.2
(can I add the sensors like this after each other)?

  condition:
  - condition: template
    value_template: '{{ states(trigger.entity_id) != ''NaN''}}'
(or should this be “unknown”)?

  action:
    service: persistent_notification.create
    data_template:
      title: Sensor NaN
      notification_id: Sensor NAN

(Below I have no idea how to write which sensor is NaN and need help)

      message: Sensor XXX is NaN

Thanks,
AseKarlsson


alias: Create a notification when devices goes NAN
description: ""

trigger:
  - platform: state
    entity_id:
      - sensor.1
      - sensor.2
    to: 
      - unknown
      - unavailable

action:
  - service: persistent_notification.create
    data:
      title: Sensor NaN
      message: >-
        {{ trigger.to_state.attributes.friendly_name }} ({{ trigger.entity_id }}) is NaN, current state: {{ trigger.to_state.state }}
      notification_id: sensor_nan

If you struggling with the yaml syntax, use the UI editor at first. Then you can copy the yaml.

Here you can see helpful variables: Automation Trigger Variables - Home Assistant

2 Likes

Thanks for your help, will try this!

Worked great after some testing, Thanks!

Glad to hear! Would you be so kind and mark the topic as solved?

@pedolsky, of coerce, missed that part!

This simple automation and how to write it will help me a lot in the future to be able to write my own notifications.
I hope this will help others as well!

//AseKarlsson

1 Like