I have an ESP with a display, and wonder if color can change according to sensor states?
For example: Showing a temperature sensor on the display, being able to show different color for different ranges?
A code example would be good!
I have an ESP with a display, and wonder if color can change according to sensor states?
For example: Showing a temperature sensor on the display, being able to show different color for different ranges?
A code example would be good!
Doesn’t it depend on the type of display?
I’m not sure I understand the question? It does need to be color display to be able to achieve it.
Yes I use colour displays dependent on sensor in HA
Are you looking for a specific colour display. There are many out there
Might be worth searching on here to help you make a choice on display.
Your question I think is to general
Thanks for your replies, but I hope you can read my first post once more.
Hi, did you find a way to display in different color depending on a sensor state? I have the same need.
No i haven’t. I gave up when all replies on this was only from this poor soul who didn’t know what he replied to. Haven’t had time to look into this no more. So if you find any I’d appreciate a heads up
I have a way to solve my specific case. I share with you the method I have used.
What I want to do:
On an ESP touchscreen running ESPHOME, display an icon that represent a light I can switch on or off in homaassistant. And I want this icon to change color depending on the light state.
Solution I have found:
First declare a text_sensor to import in ESPHOME the state of the light “on” or “off”
text_sensor:
- platform: homeassistant
id: my_light_state
entity_id: light.my_light
Then in the display component add an if block if your lambda:
display:
- platform: ili9xxx
model: S3BOX
cs_pin: GPIO5
dc_pin: GPIO4
id: lcd
pages:
- id: page1
lambda: |-
if (id(my_light_state).state == "on") {
it.image(90, 10, id(myicon), yellow);
} else {
it.image(90, 10, id(myicon));
}
This has solved my issue. I hoop this help you as well.
An other example with comparaison of numeric value:
if (id(net_power).state >= 0) {
it.image(15, 60, id(from_grid_power), red);
it.printf(80, 70, id(font_medium), red, TextAlign::TOP_LEFT, "%.0f w", id(net_power).state);
} else {
it.image(15, 60, id(to_grid_power), green);
it.printf(80, 70, id(font_medium), green, TextAlign::TOP_LEFT, "%.0f w", id(net_power).state);
}
Really nice, thanks for your feedback. I appreciate it and will look into it