rbrink / Home-Assistant-Prijsplafond

Provides Home Assistant sensors to keep track of the Dutch prijsplafond regulation.
11 stars 3 forks source link

Error after update HA to 2023.5.0 #10

Closed daantjuuh1992 closed 1 year ago

daantjuuh1992 commented 1 year ago

After updating HA to 2023.5.0 the prijsplafond sensor don't work anymore. I tested it on 2 systems, both the same errors. This is the error I get from the logs:

Logger: homeassistant.helpers.entity
Source: components/recorder/table_managers/recorder_runs.py:85
First occurred: 08:40:06 (6 occurrences)
Last logged: 08:50:06

Update for sensor.prijsplafond_gas fails
Update for sensor.prijsplafond_power fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 554, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 784, in async_device_update
    await coro
  File "/config/custom_components/prijsplafond/sensor.py", line 172, in async_update
    pos_usage += await self._get_value(entity_id)
  File "/config/custom_components/prijsplafond/sensor.py", line 192, in _get_value
    state_old = await self._get_first_recorded_state_in_month(entity_id)
  File "/config/custom_components/prijsplafond/sensor.py", line 214, in _get_first_recorded_state_in_month
    history_list = await get_instance(self.hass).async_add_executor_job(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/recorder/history/__init__.py", line 174, in state_changes_during_period
    return _target(
  File "/usr/src/homeassistant/homeassistant/components/recorder/history/modern.py", line 404, in state_changes_during_period
    run_start_ts := _get_run_start_ts_for_utc_point_in_time(hass, start_time)
  File "/usr/src/homeassistant/homeassistant/components/recorder/history/modern.py", line 583, in _get_run_start_ts_for_utc_point_in_time
    run = recorder.get_instance(hass).recorder_runs_manager.get(utc_point_in_time)
  File "/usr/src/homeassistant/homeassistant/components/recorder/table_managers/recorder_runs.py", line 85, in get
    if start >= self.recording_start:
TypeError: can't compare offset-naive and offset-aware datetimes

Is there a way to fix this?

AarvdH commented 1 year ago

Same errors overhere.

aloots commented 1 year ago

I also has this error. It has somthing to do with the template which is created.

"ValueError: Template error: float got invalid input 'None' when rendering template" Can it be the floating statement in the template?

rbrink commented 1 year ago

Thanks for noticing. Ill push an update today!

rbrink commented 1 year ago

Sorry guys.. it's going to take some time.. My development HA server crashed....... #sad story

Alfagek commented 1 year ago

@rbrink ,I'll hope you can get it quick back online and hope you have a backup ;-)

daantjuuh1992 commented 1 year ago

Is there any news on a possible update or solution to this problem?

e11en commented 1 year ago

I fixed the issue myself and created a PR for @rbrink. If other people want to use it already just override the /config/custom_components/prijsplafond/sensor.py manually with the code from the PR that you can find here: https://github.com/rbrink/Home-Assistant-Prijsplafond/pull/11/commits/0e0238a34d4a269aa4073436207d57dd40c327b2

@daantjuuh1992 @Alfagek @aloots @AarvdH

daantjuuh1992 commented 1 year ago

Thanks! The sensor works again. At 1 instance my sensor is working great. At another instance my power sensor gives the all time usage, so about 13.000 kWh. What can I do to fix this?

Alfagek commented 1 year ago

I fixed the issue myself and created a PR for @rbrink. If other people want to use it already just override the /config/custom_components/prijsplafond/sensor.py manually with the code from the PR that you can find here: 0e0238a

@daantjuuh1992 @Alfagek @aloots @AarvdH

Thanks @e11en for the fix (y). It looks like it's working again here. And not any more that annoying error in my logs ;-)

rbrink commented 1 year ago

Thanks guys! Hope to have more time upcoming weeks. Work work work