Here’s what I’ve done
In configuration.yaml
template:
- trigger:
- platform: state
entity_id:
- weather.weather_channel
action:
- service: weather.get_forecasts
data:
type: hourly
target:
entity_id: weather.weather_channel
response_variable: hourly
sensor:
- name: Weather Channel Forecast Hourly
unique_id: weather_channel_forecast_hourly
state: "{{ now() }}"
attributes:
forecast: "{{ hourly['weather.weather_channel'].forecast }}"
(note that since the get_forecasts service places the forecast under hourly > ‘weather.weather_channel’ which itself contains a period, I have to use square bracket indexing [ … ] instead of the dot (.) operator to access the forecast list. “hourly.weather.weather_channel.forecast” will not work)
In the chart card
- entity: sensor.weather_channel_forecast_hourly
unit_of_measurement: °F
filters:
- fn: |-
({ meta, vars }) => ({
xs: [...meta.forecast.map(({ datetime }) => new Date(datetime))],
ys: [...meta.forecast.map(({ temperature }) => temperature)],
})