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

reorg data extraction to prevent NoneType exceptions #95

Conversation

dan-s-github
Copy link
Contributor

Reorganised the extraction of the json response values to prevent the NoneType exceptions that occur at midnight local time.

2023-11-22 00:03:14.647 ERROR (MainThread) [custom_components.alphaess] Unexpected error fetching alphaess data: 'NoneType' object has no attribute 'get'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alphaess/coordinator.py", line 45, in _async_update_data
    _pv =  _onedateenergy.get("epv")
           ^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'

reorganize data extraction to use response from getOneDateEnergy API
Copy link
Owner

@CharlesGillanders CharlesGillanders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two separate sensors that both use SOC are a legacy from the web API - one sensor previously used a real time API and the other used a daily aggregate API. I left both sensors in place so as not to break anyone's existing automations.

@CharlesGillanders CharlesGillanders merged commit 32b01cb into CharlesGillanders:main Dec 12, 2023
3 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.

2 participants