GA Power New setup does not create entities
Closed this issue · 1 comments
Version of the custom_component
V0.1.9
Describe the bug
When setting up the integration for the very first time, the integration did not create the corrected entities (and did not enter into first time setup - pulling one year of data), causing a boot loop.
Debug log
First log when starting up
Config entry 'Southern Company Hacs' for southern_company_hacs integration not ready yet: 'southern_company_hacs:energy_cost_accountnumber'; Retrying in background
Subsequent logs
Logger: custom_components.southern_company_hacs.coordinator
Source: custom_components/southern_company_hacs/coordinator.py:117
Integration: Southern Company HACS (documentation, issues)
First occurred: 6:31:46 AM (9 occurrences)
Last logged: 6:36:09 AM
Unexpected error fetching Southern Company data: 'southern_company_hacs:energy_cost_accountnumber'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/southern_company_hacs/coordinator.py", line 61, in _async_update_data
await self._insert_statistics()
File "/config/custom_components/southern_company_hacs/coordinator.py", line 117, in _insert_statistics
_cost_sum = cost_stat[cost_statistic_id][0]["sum"] or 0.0
~~~~~~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'southern_company_hacs:energy_cost_accountnumber'
I've tried to remove the integration and HACS file, restart Home Assistant, Restart again, install the HACS file, install/setup integration and it's still the same result...
Problem solved.
The statistic_id
were still remaining in the database after removal of the custom integration, so you'll need to manually remove them before adding it again.
Editing the DB have heavy consequences if you did it wrong, so proceed with caution.
You'll need the SQLite Web Addon from HASS Addon Store. Install it, go to statistics_meta
table, query tab.
Use this SQL query to check the entities
SELECT * FROM "statistics_meta"
WHERE statistic_id LIKE "%southern_company_hacs%"
In my case, there are two entities southern_company_hacs:energy_cost_accountnumber
and southern_company_hacs:energy_usage_accountnumber
.
If you have the same error, you can try delete the two entities with
DELETE FROM "statistics_meta"
WHERE statistic_id LIKE "%southern_company_hacs%"