Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 106113

Automation -> Notification -> YAML for IF statement

$
0
0

In a notification action I want to show a notification message reporting the state of an entity. I’ve got this working using

message: >-
    En-suite window state = {{states('Binary_sensor.contact_sensor_en_suite_window')}}

The reported state shows on & off. However it’s a window sensor so I’d like to covert these results to open & closed. I’ve assumed an if statement would do the trick but I’m not familiar with the language so trying to get the right syntax from piecing together google results. Would anyone be able to point me in the direction of where I’m going wrong here please.

  message: >-
    En-suite window state = 
    {% Set state == states('Binary_sensor.contact_sensor_en_suite_window') %}
    {% if state == 'off' %} "Closed"
    {% elif state == 'on' %} "Open"
    {% else %} state
    {% endif %}]

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 106113

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>