Skip to content
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

Merged
merged 4 commits into from
Nov 15, 2024

Conversation

s-kurz
Copy link
Contributor

@s-kurz s-kurz commented Oct 9, 2024

restore the evu dates attribute and solve the TypeError: 'datetime.time' issue
fixes #249
fixes #281

@Gifford47
Copy link

Can this PR already be merged?

@s-kurz
Copy link
Contributor Author

s-kurz commented Oct 31, 2024

added min firmware version for the current power consumption sensor in alignment with the energy sensors min firmware
fixes #277

@s-kurz s-kurz changed the title restore evu date attribute correctly restore evu date attribute correctly to solve the TypeError: 'datetime.time' Oct 31, 2024
@Gifford47
Copy link

In my case the attribute EVU_DAYS isn't set correctly. It's always "" (empty string). Does it works on your own?@s-kurz

@s-kurz
Copy link
Contributor Author

s-kurz commented Oct 31, 2024

@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

@Gifford47
Copy link

Ok, thanks for the info!
I'll test it the next days

@Gifford47
Copy link

@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):
Copy link

@Gifford47 Gifford47 Nov 8, 2024

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

Copy link

@Gifford47 Gifford47 left a 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

@s-kurz
Copy link
Contributor Author

s-kurz commented Nov 8, 2024

@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

@BenPru BenPru merged commit fde3dd2 into BenPru:main Nov 15, 2024
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update 2024-10-05-beta multiple sensors disappearing
3 participants