bacco007 / sensor.opennem

OpenNEM Sensor for Home Assistant
MIT License
11 stars 5 forks source link

Beta breaks everything. No migration #10

Closed DavidFW1960 closed 2 years ago

DavidFW1960 commented 2 years ago

Version of the custom_component

2022.01.4

Configuration

Add your logs here.

Describe the bug

A clear and concise description of what the bug is.

Debug log

2022-02-06 13:25:58 ERROR (MainThread) [homeassistant.config_entries] Migration handler not found for entry OpenNEM for opennem
2022-02-06 13:29:50 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
resp = await request_handler(request)
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 220, in forwarded_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 79, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 219, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 137, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 164, in post
return await super().post(request, flow_id)
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 62, in wrapper
result = await method(view, request, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 111, in post
result = await self._flow_mgr.async_configure(flow_id, data)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 252, in async_configure
result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 325, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
File "/config/custom_components/opennem/config_flow.py", line 51, in async_step_user
if identifier in configured_instances(self.hass):
File "/config/custom_components/opennem/config_flow.py", line 17, in configured_instances
return {
File "/config/custom_components/opennem/config_flow.py", line 18, in <setcomp>
f"{entry.data[CONF_REGION]}"
KeyError: 'region'

I tried adding a second time but won't add

bacco007 commented 2 years ago

I'm having issues trying to get the migration path to work - I'll keep trying though.

This version includes a check to make sure you don't add the same region twice - if you remove the broken integration and re-add it should work though.

DavidFW1960 commented 2 years ago

I tried adding a different region as well. Didnt add or work. Rolled back for now

bacco007 commented 2 years ago

I've pushed a new beta

https://github.com/bacco007/sensor.opennem/releases/tag/2022.02.1b1

DavidFW1960 commented 2 years ago

This error originated from a custom integration.

Logger: homeassistant.config_entries Source: custom_components/opennem/init.py:112 Integration: OpenNEM (documentation, issues) First occurred: 5:04:26 PM (1 occurrences) Last logged: 5:04:26 PM

Error setting up entry OpenNEM for opennem Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 327, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/opennem/init.py", line 65, in async_setup_entry coordinator = OpenNEMDataUpdateCoordinator(hass, entry) File "/config/custom_components/opennem/init.py", line 112, in init self._region = config.data[CONF_REGION] KeyError: 'region'

DavidFW1960 commented 2 years ago

Trying to ass another region This error originated from a custom integration.

Logger: aiohttp.server Source: custom_components/opennem/config_flow.py:18 Integration: OpenNEM (documentation, issues) First occurred: 5:06:09 PM (1 occurrences) Last logged: 5:06:09 PM

Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request resp = await request_handler(request) File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle resp = await handler(request) File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 220, in forwarded_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 79, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 219, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 137, in handle result = await result File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 164, in post return await super().post(request, flow_id) File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 62, in wrapper result = await method(view, request, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 111, in post result = await self._flow_mgr.async_configure(flow_id, data) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 252, in async_configure result = await self._async_handle_step(flow, cur_step["step_id"], user_input) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 325, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) File "/config/custom_components/opennem/config_flow.py", line 51, in async_step_user if identifier in configured_instances(self.hass): File "/config/custom_components/opennem/config_flow.py", line 17, in configured_instances return { File "/config/custom_components/opennem/config_flow.py", line 18, in f"{entry.data[CONF_REGION]}" KeyError: 'region'

bacco007 commented 2 years ago

I'm struggling to replicate this one - the latest beta i've released includes diagnostics if you're on 2022.02.1+ can you export a diagnostics file?

DavidFW1960 commented 2 years ago

The integration isn't even loading to I can't do anything at all regarding diagnostics

bacco007 commented 2 years ago

I've just spun up a new environment and dropped the integration in without issue - did you install via HACS or manually? I wonder if downloading the release zip and manually installing might fix the issue?

https://github.com/bacco007/sensor.opennem/archive/refs/tags/2022.02.1b1.zip

DavidFW1960 commented 2 years ago

Well I was thinking about removing the integration and restarting and adding it back. I install via HACS, It's only asking the region when I install the integration too. I seem to remember being asked more questions when I added it before. I'm reluctant to remove the current config for it as it took a day to sort out the friendly names and make the template sensors from the attributes.

bacco007 commented 2 years ago

The new version defaults naming to sensor.opennem_{region} so in your case sensor.opennem_nsw

Looking at your opennem package (https://github.com/DavidFW1960/home-assistant/blob/master/packages/opennem.yaml) you've got two potential options I can see:

  1. Update the package to the new sensor name sensor.opennem to sensor.opennem_nsw
  2. change the sensor name in the UI to sensor.opennem
DavidFW1960 commented 2 years ago

I think i did rename it to nsw1 as per the package. I might just delete the integration tomorrow and readd it.

DavidFW1960 commented 2 years ago

ok. I removed the integration and added it back after restarting. All errors resolved now and I renamed the sensor in the package so all is working now.