briis / hass-weatherflow

Home Assistant Integration for WeatherFlow Stations
MIT License
67 stars 11 forks source link

Constant Errors "while processing state change" #21

Closed Colorado4Wheeler closed 2 years ago

Colorado4Wheeler commented 2 years ago

I have been getting a lot of errors in my log (as in 790 in less than 12 hours) about state changes on my Tempest. From what I can see, the native interface on the Weatherflow is fine, but reporting back to HA seems to be causing a conflict:

021-12-28 06:50:12 ERROR (MainThread) [homeassistant.helpers.event] Error while processing state change for sensor.weatherflow_visibility
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 269, in _async_state_change_dispatcher
    hass.async_run_hass_job(job, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 433, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1072, in _refresh
    self.hass.async_run_hass_job(self._job, event, updates)
  File "/usr/src/homeassistant/homeassistant/core.py", line 433, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 306, in _handle_results
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 505, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 540, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/weather/__init__.py", line 251, in state_attributes
    forecast_entry = dict(forecast_entry)
ValueError: dictionary update sequence element #0 has length 1; 2 is required

The above error shows for visibility, but I get errors at about the same time that are identical for wind direction, wind speed, air temperature, relative humidity. The connection to my device is fairly close to the base station, it is about 50 feet away line-of-sight, and the base station has a solid connection to my wifi network and the battery on the Tempest is typically between 77 and 80%.

briis commented 2 years ago

From the above error I cannot really see that this Integration is causing the issue, as these are common Home Assistant files. Is WeatherFlow the only Weather integration you have installed? Just to be sure we are looking in the right place.

Assuming this integration is causing the issues:

Colorado4Wheeler commented 2 years ago

The message does read:

Error while processing state change for sensor.weatherflow_visibility

And none of these appeared prior to installing the WeatherFlow component. I don't have any other weather stations at all, just this one. I'm on HA 2021.12.5 and my weather station is ST-00056893.

Colorado4Wheeler commented 2 years ago

Although, it occurs to me that I also tap into the weather flow data for a custom weather template (before I realized the integration contained a weather domain entity, I've now disabled that and I'll let you know if the error goes away.

briis commented 2 years ago

Thanks. Your station ID is not ST-00056893, that is the serial number of your Tempest Device. If you used this number when setting it up, it will not work. The Station ID is a number only. Look here on how to get it: https://github.com/briis/hass-weatherflow#station-id

Colorado4Wheeler commented 2 years ago

I wasn't sure which number was needed, here is what is on the URL: 65947 (and it is the number I configured for the integration as well). The integration is working fine, I get the results, just that error kept popping up.

briis commented 2 years ago

Thanks. The error above if for the Weather Entity, so basically the forecast piece of this Integration. You will have two of those: 1 with Daily Data and one with Hourly data. Are these populated with correct data?

Colorado4Wheeler commented 2 years ago

They appear to be correct. They do differ from my other 5 weather sources as far as forecast, but the highs and lows are within acceptable tolerances. That is to say that, yes, I believe them to be relatively accurate.

briis commented 2 years ago

I have just setup the Integration with your station id, and everything is looking fine, and I have no errors in the log file. I will let it run for a while to see if it starts producing errors.

Colorado4Wheeler commented 2 years ago

I also updated to 2021.12.6 and removed the custom weather template that I was using and have not yet seen any messages, perhaps it was the cause of the error.

briis commented 2 years ago

Yes the custom template might very well have been the cause. What did you try to achieve in the template? Maybe I can built it directly in the integration?

Colorado4Wheeler commented 2 years ago

It was before I realized there was a daily and hourly weather component in the add-on, so I was just taking some of the values from the Tempest and adding it to a custom weather template so I could have local values and the forecast from Dark Sky (whom I found to be the most accurate) in order to have a "better" weather card in my Lovelace.

briis commented 2 years ago

Ok. Forecast data quality is out of my hands, as I just deliver the data WeatherFlow supplies. Remember Dark Sky will go away in a little while, when Apple shuts it down.

If your station is new, it will take a little while, but the Forecast will improve over time, as it uses your Tempest data in some AI routines to increase forecast quality.

Colorado4Wheeler commented 2 years ago

Yea, Dark Sky is gone as of end of 2022, however from what I've read that is not a certainty. It was supposed to go away end of 2021 but got extended another year. Interesting about the AI forecast model though!

briis commented 2 years ago

Let su see what Apple does with it. Anyway, close this issue when your are certain the error does not surface again.

Colorado4Wheeler commented 2 years ago

So far nothing, I'm closing it now and will re-open if they pop back up again today. Thank you for the help!