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

'HistoricalState' object has no attribute 'when' #42

Closed
lazynoda opened this issue Mar 16, 2023 · 1 comment
Closed

'HistoricalState' object has no attribute 'when' #42

lazynoda opened this issue Mar 16, 2023 · 1 comment

Comments

@lazynoda
Copy link

Describe the bug
When starting HA, the following error log appears:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/homeassistant_historical_sensor/sensor.py", line 155, in async_write_ha_historical_states
    await self._async_save_states_into_statistics(hist_states)
  File "/usr/local/lib/python3.10/site-packages/homeassistant_historical_sensor/sensor.py", line 203, in _async_save_states_into_statistics
    statistics_data = await self.async_calculate_statistic_data(
  File "/config/custom_components/ideenergy/sensor.py", line 107, in async_calculate_statistic_data
    hist_states = [x for x in hist_states if x.when >= latest["end"]]
  File "/config/custom_components/ideenergy/sensor.py", line 107, in <listcomp>
    hist_states = [x for x in hist_states if x.when >= latest["end"]]
AttributeError: 'HistoricalState' object has no attribute 'when'

To Reproduce

  1. I had wip/historical-sensor branch running. It stopped working when I updated HA to 2023.3.X due to changes in DB.
  2. As mentioned in Request for testing #34, I pulled the main branch, changed the HISTORICAL_PERIOD_LENGHT constant to timedelta(days=15), and restarted everything.

Environment

  • HomeAssistant version: 2023.3.4
  • ideenergy integration version: main branch, commit 288ab92
  • Instalation method: docker
  • i-de.es advanced user: yes
  • Did I read the FAQ?: of course 😅

Expected behavior
After restarting HA, I expected the integration to download past consumption data and import it into Energy dashboard.

Logs
Working on it to avoid leaking data

Screenshots
N/A

Additional context
Like said, I came from wip/historical-sensor branch due to #34. I have 2 contracts, one is "disabled" but it has never been an issue before.

ldotlopez added a commit that referenced this issue Mar 16, 2023
@lazynoda
Copy link
Author

That commit fixed the issue @ldotlopez ❤️ now it's just a matter of changing the Delta to get past data. Thank you!

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

No branches or pull requests

2 participants