Rofo
(Ro)
October 16, 2024, 1:00pm
1
Now that we have to make a service call to get weather info, how would I translate the following automation into esphome yaml so that I can grab the entities and display home on an esp32 based device:-
actions:
- target:
entity_id: weather.forecast_home
data:
type: hourly
response_variable: forecast_data
action: weather.get_forecasts
So I know how to make service calls in esphome, but I am not sure how to get the return value into an object I can then parse to get the data out.
Rofo
(Ro)
October 16, 2024, 1:04pm
2
More forum searching and I think I have my answer here:-
Early this year I was disappointed to update my HA core only to find that I was no longer able to get data to various weather station outputs (I have two epaper displays running through ESP Home and also a custom card within the HA app, and this is repeated with modifications for another instance I run at my holiday home).
I rolled back my HA core to 2024.1.6, which was apparently the last version which allowed the legacy templates to operate. Since then I have been resolutely staying away from…
Rofo
(Ro)
October 16, 2024, 2:17pm
3
I’m not sure if my syntax is correct, can anyone confirm:-
template: !include templates.yaml
## Weather based template trigger to send esphome devices data
- trigger:
- trigger: time
at: "07:00:00"
action:
- action: weather.get_forecasts
data:
type: daily
target:
entity_id: weather.forecast_home
response_variable: forecast_data
sensor:
- name: "Forecast Temperature (current)"
unique_id: forecast_temperature_current
unit_of_measurement: "%"
state: >
{{ forecast_data['weather.forecast_home'].forecast[0].temperature }}
- name: "Forecast Temperature (high)"
unique_id: forecast_temperature_high
unit_of_measurement: "%"
state: >
{{ forecast_data['weather.forecast_home'].forecast |
selectattr('datetime', 'search', now().timestamp() |
timestamp_custom('%Y-%m-%d')) | map(attribute='temperature') | max }}
- name: "Forecast Temperature (low)"
unique_id: forecast_temperature_low
unit_of_measurement: "%"
state: >
{{ forecast_data['weather.forecast_home'].forecast |
selectattr('datetime', 'search', now().timestamp() |
timestamp_custom('%Y-%m-%d')) | map(attribute='temperature'){ | min }}
Rofo
(Ro)
October 16, 2024, 3:22pm
4
Update: seems to work, for anyone else that wants to use this.
1 Like