I’ve spent 6hrs trying to get a plot of the temperature from an hourly weather forecast to work. I’ve tried every damn template and example in every damn post. Feel like I’m being gaslit… Anyone know what is going wrong here?
I have the default weather.forecast_home from the Meteorologisk institutt (Met.no) integration ( http://homeassistant.local:8123/config/integrations/integration/met )
In dev tools services ( http://homeassistant.local:8123/developer-tools/service ) i can do:
service: weather.get_forecasts
data:
type: hourly
target:
entity_id:
- weather.forecast_home
and i get back:
weather.forecast_home:
forecast:
- condition: rainy
datetime: "2024-05-18T15:00:00+00:00"
wind_bearing: 337.9
cloud_coverage: 52.3
temperature: 19.7
wind_speed: 13.7
precipitation: 0.2
humidity: 64
- condition: partlycloudy
datetime: "2024-05-18T16:00:00+00:00"
wind_bearing: 60.5
cloud_coverage: 69.5
temperature: 18.4
wind_speed: 13.7
precipitation: 0
humidity: 71
- condition: sunny
datetime: "2024-05-18T17:00:00+00:00"
wind_bearing: 98.3
cloud_coverage: 4.7
temperature: 18.4
wind_speed: 4.3
precipitation: 0
humidity: 70
etc
But as we see in this huge thread, those attributes are not supposed to be used anymore, so we need to make a custom sensor to replace it.
In the config helpers ( http://homeassistant.local:8123/config/helpers ) I have created a template sensor:
This is using a template that worked for numerous users on march 8th ( Unsure How To Use Hourly Forecast Information (Since 2024.3.0) · Issue #112628 · home-assistant/core · GitHub ), although I did see that the weather.home
has changed to weather.forecast_home
between then and now, so I made that adjustment
template:
- trigger:
- platform: time_pattern
hours: /1
- platform: homeassistant
event: start
action:
- service: weather.get_forecasts
data:
type: hourly
target:
entity_id: weather.forecast_home
response_variable: hourly
sensor:
- name: Weather Hourly
state: "{{ states('weather.forecast_home') }}"
attributes:
temperature: "{{ state_attr('weather.forecast_home', 'temperature') }}"
dew_point: "{{ state_attr('weather.forecast_home', 'dew_point') }}"
temperature_unit: "{{ state_attr('weather.forecast_home', 'temperature_unit') }}"
humidity: "{{ state_attr('weather.forecast_home', 'humidity') }}"
cloud_coverage: "{{ state_attr('weather.forecast_home', 'cloud_coverage') }}"
pressure: "{{ state_attr('weather.forecast_home', 'pressure') }}"
pressure_unit: "{{ state_attr('weather.forecast_home', 'pressure_unit') }}"
wind_bearing: "{{ state_attr('weather.forecast_home', 'wind_bearing') }}"
wind_speed: "{{ state_attr('weather.forecast_home', 'wind_speed') }}"
wind_speed_unit: "{{ state_attr('weather.forecast_home', 'wind_speed_unit') }}"
visibility_unit: "{{ state_attr('weather.forecast_home', 'visibility_unit') }}"
precipitation_unit: "{{ state_attr('weather.forecast_home', 'precipitation_unit') }}"
forecast: "{{ hourly['weather.forecast_home'].forecast }}"
However it is shown as unavailable and doesn’t get any data:
Which means then it fails to plot data in a plotly graph card:
type: custom:plotly-graph
hours_to_show: 16
time_offset: 3h
entities:
- entity: sensor.smile_anna_outdoor_temperature
line:
width: 3
color: orange
- entity: sensor.smile_anna_outdoor_temperature
name: Temperature yesterday
time_offset: 1d
line:
width: 1
dash: dot
color: orange
- entity: sensor.weather_hourly
attribute: temperature
unit_of_measurement: °C
time_offset: 0d
name: Forecast temperature
line:
width: 1
dash: dot
color: grey
Any help would be appreciated