Hello, I am currently working on a project where I am using the Sonoff NSPanel device integrated with ESPHome and Nextion Editor to create a user interface. Everything has been going smoothly so far, but I’ve encountered a roadblock when trying to display a weather symbol on the screen.
I have successfully connected the Sonoff NSPanel to my ESPHome project and have been able to display other elements on the screen using the Nextion Editor. However, when I try to display the weather symbol, my code doesn’t seem to work as expected. - platform: homeassistant id: weather_symbol entity_id: weather.home on_value: then: - wait_until: switch.is_on: nextion_init - lambda: |- int symbol=8; // 5 is a empty box. if (id(weather_symbol).state == "clear-night") { symbol=9; } else if (id(weather_symbol).state == "cloudy") { symbol=10; if (id(sun_sun).state == "below_horizon") { symbol=9; } } else if (id(weather_symbol).state == "fog") { symbol=11; } else if (id(weather_symbol).state == "hail" || id(weather_symbol).state == "snowy-rainy") { symbol=15; } else if (id(weather_symbol).state == "lightning") { symbol=14; } else if (id(weather_symbol).state == "lightning-rainy" || id(weather_symbol).state == "exceptional") { symbol=21; if (id(sun_sun).state == "below_horizon") { symbol=20; } } else if (id(weather_symbol).state == "partlycloudy") { symbol=16; if (id(sun_sun).state == "below_horizon") { symbol=17; } } else if (id(weather_symbol).state == "pouring") { symbol=12; } else if (id(weather_symbol).state == "rainy") { symbol=18; } else if (id(weather_symbol).state == "snowy") { symbol=13; } else if (id(weather_symbol).state == "sunny") { symbol=22; if (id(sun_sun).state == "below_horizon") { symbol = 9; } } else if (id(weather_symbol).state == "windy" || id(weather_symbol).state == "windy-variant") { symbol=23; } else { symbol=16; } id(disp1).send_command_printf("Thermostat.weather_symbol.pic=%i", symbol);
I use Picture component in Nextion Editor, objname is weather_symbol and number in pic indicates which image should be displayed.
Code is installed correctly, but weather_symbol is still a default image.
I would greatly appreciate any guidance or suggestions to help me resolve this issue.
Hi and welcome. You have sort have got the idea about posting your yaml - but not quite right. It should look the same in your post as in the ESPHome editor, i.e.:
sensor:
- platform: homeassistant
id: weather_symbol
entity_id: weather.home
on_value:
then:
- wait_until:
switch.is_on: nextion_init
- lambda: |-
int symbol=8; // 5 is a empty box.
if (id(weather_symbol).state == "clear......
# etc...
yaml is all about indentation and if we can’t see that it makes it impossible to debug.
Your logic looks fine - maybe someone with a Nextion display can chime in with an idea. I would change the topic title to include the fact that this is Nextion as they have their own user-base who may not spot the topic.
There is also a quiet long thread on the Sonoff panel that may be worth a look.
I have almost the samecode for my nspanel, except for the last ‘else’ presenting symbol 16…is that your ‘default’ one? Or…is the one you call ‘default’ anywhere in this picture set?
Yes, I use HA to display temperature and it is displayed correctly.
[C][homeassistant.text_sensor:023]: Homeassistant Text Sensor ‘sun_sun’
[C][homeassistant.text_sensor:024]: Entity ID: ‘sun.sun’
[C][homeassistant.text_sensor:023]: Homeassistant Text Sensor 'weather_symbol' [14:15:22][C][homeassistant.text_sensor:024]: Entity ID: 'weather.home'
I am not sure where I can find that in the log.
open the log, open another window HA dev tools and go to states tab, find weather.home and update the state…not sure if this is too cryptic as not sure how far your knowledge goes …not meant patronising