home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.82k stars 30.51k forks source link

Buienradar causes template weather integration to error #47805

Closed Mariusthvdb closed 3 years ago

Mariusthvdb commented 3 years ago

The problem

as title

What is version of Home Assistant Core has the issue?

2021.3.3

What was the last working version of Home Assistant Core?

?

What type of installation are you running?

Home Assistant OS

Integration causing the issue

template weather

Link to integration documentation on our website

https://www.home-assistant.io/integrations/weather.template/

Example YAML snippet

# Put your YAML below this line
{{state_attr('weather.buienradar','forecast')}}

Anything in the logs that might be useful for us?

# Put your logs below this line
Logger: homeassistant.helpers.event
Source: components/weather/__init__.py:181 
First occurred: 1:51:43 PM (2 occurrences) 
Last logged: 1:51:46 PM

Error while processing state change for sensor.openweathermap_wind_speed
Error while processing state change for sensor.luftdaten_37248_pressure
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 280, in _async_state_change_dispatcher
    hass.async_run_hass_job(job, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 435, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1005, in _refresh
    self.hass.async_run_hass_job(self._job, event, updates)
  File "/usr/src/homeassistant/homeassistant/core.py", line 435, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 251, in _handle_results
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 295, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 321, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/weather/__init__.py", line 181, in state_attributes
    forecast_entry = dict(forecast_entry)
ValueError: dictionary update sequence element #0 has length 1; 2 is required

see: https://community.home-assistant.io/t/template-weather-integration-throws-valueerror-dictionary-update-sequence-element-0-has-length-1-2-is-required/289427/2

remotely related: https://github.com/home-assistant/core/issues/47450

2 top lines in the error are unrelated, caused by different templates.

different in output for the forecast integrations:

Schermafbeelding 2021-03-12 om 15 44 27
probot-home-assistant[bot] commented 3 years ago

buienradar documentation buienradar source (message by IssueLinks)

probot-home-assistant[bot] commented 3 years ago

Hey there @mjj4791, @ties, mind taking a look at this issue as its been labeled with an integration (buienradar) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

Mariusthvdb commented 3 years ago

this is still odd, now erroring on the condition template, that is showing 'unknown'

Schermafbeelding 2021-03-19 om 09 32 42 Schermafbeelding 2021-03-19 om 09 33 32
  - platform: template
    name: Composite
    condition_template: >
      {{states('sensor.br_condition')}}
    temperature_template: >
      {{states('sensor.weatherbit_apparent_temperature')|float}}
    humidity_template: >
      {{states('sensor.weatherbit_humidity')|float}}
    forecast_template: >
      {{state_attr('weather.dark_sky','forecast')}}
    pressure_template: >
      {{states('sensor.luftdaten_37248_pressure')|float}}
    wind_speed_template: >
      {{states('sensor.openweathermap_wind_speed')|float}}

for full disclosure.

in template editor all is well:

Schermafbeelding 2021-03-19 om 09 32 08

@dgomes would this be an issue with Buienradar too? All templates show correctly, and even the individual Buienradar sensors show fine:

Schermafbeelding 2021-03-19 om 09 34 49 Schermafbeelding 2021-03-19 om 09 36 00

simply change the condition_template to

    condition_template: >
      {{states('sensor.openweathermap_condition')}}

solves the issue..

Schermafbeelding 2021-03-19 om 10 37 49 Schermafbeelding 2021-03-19 om 10 37 16
dgomes commented 3 years ago

I would say that's BR issue...

Mariusthvdb commented 3 years ago

well tbh, why? All BR entities are showing as expected in all settings in Lovelace, except in the weather template integration...

dgomes commented 3 years ago

Yet other integrations condition works...

Mariusthvdb commented 3 years ago

well yes, of course, that's why I opened this issue in the first place. My point was, since you've changed the forecast entities of BR in #47809, you might also have a look at this. Ive shortened the issue title accordingly to reflect that.