Hi, all.
I am trying to figure out how to use weather from Home Assistant in ESPHome. I have read many threads on here, including:
I also visited the linked posts in those posts.
I am able to get the current conditions, but I am still not able to get anything from weather.forecast_home.forecast
– that is, I can’t read any of the array.
I have tried loading this into my configuration.yaml
file:
- platform: template
sensors:
wx_temp_low:
friendly_name: "Today Low Temperature"
value_template: >-
{{ state_attr('weather.forecast_home','forecast')[0].templow }}
wx_temp_high:
friendly_name: "Today High Temperature"
value_template: >-
{{ state_attr('weather.forecast_home','forecast')[0].temperature }}
Then I added this to my ESPHome device file:
- platform: homeassistant
id: temp_low
entity_id: sensor.wx_temp_low
internal: True
- platform: homeassistant
id: temp_high
entity_id: sensor.wx_temp_high
internal: True
I tried printing that like this:
it.printf(0,0,id(font_roboto_medium22), id(my_red), TextAlign::TOP_LEFT, "min/max: %.0f/%.0f", id(temp_low).state, id(temp_high).state);
But that does not work.
I tried using this value – {{ state_attr('weather.home', 'forecast')[0].temperature }}
– like this, but this does not work either:
it.printf(0,50,id(font_roboto_medium22), id(my_red), TextAlign::TOP_LEFT, "min/max: %.0f", {{ state_attr('weather.forecast_home', 'forecast')[0].templow }}, {{ state_attr('weather.forecast_home', 'forecast')[0].temperature }});
That complains about the curly braces, but when I remove those, I get an error that state_attr
is not defined.
For the life of me, I cannot read anything under the weather.forecast_home.forecast
array.
Can someone please point me in the right direction here?
Thanks.