I’ve been struggling to properly detect if a text_sensor or sensor has the value of NULL.
I have a text_sensor with an if statement to either display page1 or page3 depending on the condition:
text_sensor:
- platform: homeassistant
id: sonos_media_channel
entity_id: media_player.sonos_arc
attribute: media_channel
- platform: homeassistant
entity_id: media_player.android_tv1
id: android_tv
on_value:
then:
- if:
condition:
lambda: 'return id(android_tv).state != "off" || id(sonos_media_channel).state != NULL );'
then:
- logger.log: "TV is On"
- display.page.show: page1
else:
- logger.log: "TV is Off"
- display.page.show: page3
This check does not work. I also tried setting up a “normal” non text sensor, but that also results in not working code.
My workarround for now is using a Home Assistant template to determine that a value “is defined”. But it would be much nicer if it could be contained within the Esphome configuration of the device.
Can someone explain how I can reliably check if a text_sensor or a normal sensor has a value of NULL?