-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
restore evu date attribute correctly to solve the TypeError: 'datetime.time' #283
Conversation
Can this PR already be merged? |
added min firmware version for the current power consumption sensor in alignment with the energy sensors min firmware |
In my case the attribute EVU_DAYS isn't set correctly. It's always "" (empty string). Does it works on your own?@s-kurz |
@Gifford47 Its similar for me. I just fixed the issue that came from the attribute restoration. To test this part I manually change the attributes and then did a restart, which does restored them correctly. I never checked the logic of how the dates are actually set, nor am I sure if they should be set for my setup |
Ok, thanks for the info! |
@BenPru Please don´t merge yet, there's a smaller bug in the logic. I'll fix it in a few days. |
@@ -394,16 +396,18 @@ def _calc_next_evu_event_minutes(self) -> int | None: | |||
return None | |||
evu_hours = (24 if evu_time < time_now else 0) + evu_time.hour | |||
weekday = datetime.today().weekday() | |||
if not isinstance(self._attr_cache[SA.EVU_DAYS], list): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here's a bug. it has to be checked if the attribute is a string. if yes, convert it to a list to append a new weekday. Please replace with the following:
if isinstance(self._attr_cache[SA.EVU_DAYS], str):
self._attr_cache[SA.EVU_DAYS] = self._attr_cache[SA.EVU_DAYS].split(',')
elif not isinstance(self._attr_cache[SA.EVU_DAYS], list):
self._attr_cache[SA.EVU_DAYS] = list() # failsafe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on line 399 is a bug. it has to be checked if the attribute is a string. if yes, convert it to a list to append a new weekday. Please replace with the following:
if isinstance(self._attr_cache[SA.EVU_DAYS], str):
self._attr_cache[SA.EVU_DAYS] = self._attr_cache[SA.EVU_DAYS].split(',')
elif not isinstance(self._attr_cache[SA.EVU_DAYS], list):
self._attr_cache[SA.EVU_DAYS] = list() # failsafe
@Gifford47 I made the change. But as I said I don't have a good way to test it since EVU is never active for me. I would propose we merge it at this state wether the evu dates are working now or not, so we at least fix the other more problematic issues with the disapperaing/unavailable sensors |
restore the evu dates attribute and solve the TypeError: 'datetime.time' issue
fixes #249
fixes #281