Good morning
On a small DIY project, I put 2 relays, 2 door sensors, 1 Dallas DS18B20 probe and an OLED screen on an ESP32.
On the OLED screen, I currently display
- an mdi:fan icon if the relay is ON
- an mdi:fan-off icon if the relay is OFF
There I now want to retrieve the information from HA of a light.ecl_baie_led_haut to do a bit of the same thing, namely display:
- an mdi:lightbulb-outline icon if the relay is ON
- an mdi:lightbulb-off-outline icon if the relay is OFF
here is some of my code to do it:
sensor:
- platform: homeassistant
id: led
entity_id: light.ecl_baie_led_haut
internal: true
display:
- platform: ssd1306_i2c
model: "SSD1306 128x64"
address: 0x3C
update_interval: 0.2s
lambda: |-
# Works welln
if (id(ventillateur_1).state) {
it.print(0, 0, id(font5), "\U000F0210");
} else {
it.print(0, 0, id(font5), "\U000F081D");
}
# Works well
if (id(ventillateur_2).state) {
it.print(0, 32, id(font5), "\U000F0210");
} else {
it.print(0, 32, id(font5), "\U000F081D");
}
# doesn't work at all
if (id(led).state == true) {
it.print(40, 0, id(font5), "\U000F0336");
} else {
it.print(40, 0, id(font5), "\U000F0E50");
}
Error message in the logs:
[20:43:13][W][homeassistant.sensor:015]: 'light.ecl_baie_led_haut': Can't convert 'on' to number!
[20:43:13][D][sensor:094]: 'led': Sending state nan with 1 decimals of accuracy
[20:43:26][W][homeassistant.sensor:015]: 'light.ecl_baie_led_haut': Can't convert 'off' to number!
[20:43:26][D][sensor:094]: 'led': Sending state nan with 1 decimals of accuracy
Thank you for your help on the subject