brewston
(Tim Jones)
March 9, 2021, 5:22pm
1
Hiya
I’m playing with an e-ink display attached a nodeMCU running latest ESPehome. In the display component I have :
lambda: |-
if (id(conditionswd).state == "overcast clouds") {
it.print(25, 0, id(conditions), "\U000F0590");}
Where conditionswd is previously defined from the open weather provider ie :
- platform: homeassistant
name: forecast
id: conditionswd
entity_id: sensor.openweathermap_weather
internal: true
That works just fine, but what I really want is to display a different glyph during day or night. I have defined the sun component :
sun:
latitude: 48.8584
longitude: 2.2945
and therefore I wanted to achieve something like this :
if ((id(conditionswd).state == "clear sky") && (sun.is_below_horizon == True)){
it.print(25, 0, id(conditions), "\U000F0594");}
but the syntax checker during compilation (The yaml validator says its fine) complains about sun.is_below_horizon
Any suggestions on the correct syntax ? Thanks
birchman
(Mattias Björkman)
March 9, 2021, 9:22pm
2
Hi
I think sun.is_below_horizon
can only be called in the automation framework and is not available in a template. Maybe someone with better C++ skills knows.
But you could get the elevation. So if that is below 0 it should be night.
sensor:
- platform: sun
id: elev
name: Sun Elevation
type: elevation
Use this statement in your lambda. (id(elev).state <0)
for thing during the night.
Maybe a solution.
/Mattias
brewston
(Tim Jones)
March 10, 2021, 9:11am
3
Thanks for your reply, still not working
src/main.cpp: In lambda function:
src/main.cpp:591:50: error: expected identifier before '(' token
if (conditionswd->state == "clear sky") && (elev->state < 0) {
If I remove the parenthesis around it, I get a slightly different error :
src/main.cpp: In lambda function:
src/main.cpp:591:54: error: expected ';' before '->' token
if (conditionswd->state == "clear sky") && elev->state < 0 {
^
src/main.cpp:591:47: warning: statement has no effect [-Wunused-value]
if (conditionswd->state == "clear sky") && elev->state < 0 {
birchman
(Mattias Björkman)
March 10, 2021, 11:55am
4
Hi
I looks like you missing a left parenthesis. The the whole statement after if should be in a parenthesis.
Like this:
if ((id(conditionswd).state == "clear sky") && (id(elev).state <0)){
it.print(25, 0, id(conditions), "\U000F0594");}
/Mattias
1 Like
brewston
(Tim Jones)
March 10, 2021, 12:13pm
5
sweet! That compiled, I now have
if ((id(conditionswd).state == "clear sky") && (id(elev).state <0)) {
it.print(25, 0, id(conditions), "\U000F0594");}
if ((id(conditionswd).state == "clear sky") && (id(elev).state >0)) {
it.print(25, 0, id(conditions), "\U000F0599");}
I need it to stop raining to prove it really works