BenPru / luxtronik

Luxtronik integration for Home Assistant
MIT License
68 stars 23 forks source link

Update for number.luxtronik2_domestic_water_thermal_desinfection_target fails #82

Closed rhammen closed 1 year ago

rhammen commented 1 year ago

This error originated from a custom integration.

Logger: homeassistant.helpers.entity Source: custom_components/luxtronik2/number.py:397 Integration: Luxtronik First occurred: 00:16:13 (147 occurrences) Last logged: 01:29:13

Update for number.luxtronik2_domestic_water_thermal_desinfection_target fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 538, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 736, in async_device_update raise exc File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/luxtronik2/number.py", line 397, in update if domesticWaterCurrent >= float(self.native_value) and (self._last_thermal_desinfection is None or self._last_thermal_desinfection < datetime.now().date): TypeError: '<' not supported between instances of 'str' and 'builtin_function_or_method'

BenPru commented 1 year ago

Please try the last pre-release 2022.02.02

rhammen commented 1 year ago

With 2022.02.02 I didn't see any such errors anymore, so I will close the issue.

rhammen commented 1 year ago

This error originated from a custom integration.

Logger: homeassistant.helpers.entity Source: custom_components/luxtronik2/number.py:397 Integration: Luxtronik First occurred: February 6, 2023 at 00:21:47 (1071 occurrences) Last logged: February 6, 2023 at 18:17:51

Update for number.luxtronik2_domestic_water_thermal_desinfection_target fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 538, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 736, in async_device_update raise exc File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/luxtronik2/number.py", line 397, in update if domesticWaterCurrent >= float(self.native_value) and (self._last_thermal_desinfection is None or self._last_thermal_desinfection == "" or self._last_thermal_desinfection < datetime.now().date()): TypeError: '<' not supported between instances of 'str' and 'datetime.date'


After HA starts up, everything is OK: no error. The errors occurs from the moment the Thermal desinfection took place I'd say the problem is self._last_thermal_desinfection is a string, and is being compared to datetime.now().date() which is a datetime.date

BenPru commented 1 year ago

@rhammen Please try the current main draft. I'm have currently installed the new core-preview and can not test this.

rhammen commented 1 year ago

@BenPru Ok, I have updated my local install with these changes. My next Thermal desinfection run is on Monday, I'll report back afterwards. I do have 1 question regarding this check: cast(date, self._last_thermal_desinfection) < datetime.now().date() This basically says you only want to update the last thermal desinfection date, if the current last_thermal_desinfection date is "in the past".

What is the reason you don't want to update self._last_thermal_desinfection when self._last_thermal_desinfection is "in the future"? I can quickly think of 2 reasons why the last_thermal_desinfection date could be "in the future": 1) User made an error with entering the the date/time of the system then is running HA, e.g. entered month = 09 instead of 08. or the wrong year. When the user corrects the error, you do not want to update the last_thermal_desinfection date? 2) The weekend when the clock is returning to winter-time, the clock is set back from 03:00 --> 02:00. So last_thermal_desinfection date could then be somewhere between 02:00 and 03:00. In this case you also do not want to update the last_thermal_desinfection date/time?

rhammen commented 1 year ago

New error with the latest version, after my thermal desinfection ran last night:

This error originated from a custom integration.

Logger: homeassistant.helpers.entity Source: custom_components/luxtronik2/number.py:397 Integration: Luxtronik First occurred: 00:17:39 (512 occurrences) Last logged: 04:33:10

Update for number.luxtronik2_domestic_water_thermal_desinfection_target fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 538, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 736, in async_device_update raise exc File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/luxtronik2/number.py", line 397, in update if domesticWaterCurrent >= float(self.native_value) and (self._last_thermal_desinfection is None or self._last_thermal_desinfection == "" or (isinstance(self._last_thermal_desinfection, date) and cast(date, self._last_thermal_desinfection) < datetime.now().date())): NameError: name 'date' is not defined

BenPru commented 1 year ago

Sorry, missing import. Should be fixed.

rhammen commented 1 year ago

Did not see this error recently, so confirm it is fixed.