elad-bar / ha-blueiris

Integration with Blue Iris Video Security Software
179 stars 42 forks source link

Config Flow error/Unable to install 2024.6.0.dev202405200218 #230

Closed TheOneOgre closed 3 months ago

TheOneOgre commented 3 months ago

Was having issues with the integration showing 500 error, tried reinstalling but am running into the same config flow error. Have tried completely deleting and re-installing from HACS to no avail. Below is the error shown in the system log.


Logger: aiohttp.server
Source: /usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py:421
First occurred: 6:04:12 PM (4 occurrences)
Last logged: 6:11:42 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 210, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp_session/__init__.py", line 199, in factory
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 295, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 73, in wrapper
    return await method(view, request, data, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 172, in post
    return await self._post_impl(request, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 179, in _post_impl
    return await super()._post_impl(request, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 84, in _post_impl
    result = await self._flow_mgr.async_init(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1250, in async_init
    flow, result = await self._async_init(flow_id, handler, context, data)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1280, in _async_init
    result = await self._async_handle_step(flow, flow.init_step, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 517, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/blueiris/config_flow.py", line 39, in async_step_user
    await self._config_flow.initialize(self.hass)
  File "/config/custom_components/blueiris/managers/config_flow_manager.py", line 63, in initialize
    await self.update_data(data, CONFIG_FLOW_INIT)
  File "/config/custom_components/blueiris/managers/config_flow_manager.py", line 97, in update_data
    await self._update_entry()
  File "/config/custom_components/blueiris/managers/config_flow_manager.py", line 240, in _update_entry
    entry = ConfigEntry(
            ^^^^^^^^^^^^
TypeError: ConfigEntry.__init__() missing 1 required keyword-only argument: 'unique_id'
kramttocs commented 3 months ago

Have you tested on a non dev install of HA? I am on the latest (non dev) and just did Configure with changing some options and no issue.

I know a long time ago users had to manually delete files left over from an uninstall. It wasn't this error but worth a shot. We've had the unique id warning for awhile but not with a stack like this.

TheOneOgre commented 3 months ago

Thanks for the quick response. I made sure all files were removed upon removing the integration, everything was deleted properly, the only remnants I found were in /.storage/.blueiris, which I deleted, that did not fix the issue.

Reverting back from dev to main branch allows the config flow to perform properly, so there seems to be something breaking in one of the latest dev releases.

kramttocs commented 3 months ago

Excellent! Can reopen if something crops up but will chalk it up to a dev bug.

TheOneOgre commented 3 months ago

Excellent! Can reopen if something crops up but will chalk it up to a dev bug.

So with that being said, should it be reopened if it stays an issue with the dev branch for x number of days/release? Or should it only be reopened if it persists into a stable release?

kramttocs commented 3 months ago

So I actually looked into that last night and meant to reopen this earlier. First off, I don't understand what all is going on in the setup code for this integration and have avoided touching it as I believe a lot of work is being done manually vs letting HA logic handle it. Will defer to @elad-bar on that.

@elad-bar I see your shinobi integration doesn't utilize a config_flow_manager file. Not sure the work involved but should this one move away from that? Thanks as always.

user45876 commented 3 months ago

It is still the same issue with a current beta release. Thanks for your efforts :)

Core 2024.6.0b4
kramttocs commented 3 months ago

Some related info here: https://community.home-assistant.io/t/configflowhandler-and-optionsflowhandler-managing-the-same-parameter/365582/28

Gut feeling (as I mentioned above) is that things need reworked to let HA handle a lot of the config management logic. A band-aid could be adding unique_id to the ConfigEntry here: https://github.com/elad-bar/ha-blueiris/blob/master/custom_components/blueiris/managers/config_flow_manager.py#L238 But I am not positive yet if there is a valid 'unique_id' that would work and not mess things up. Even if it was a new guid each time. All of this (creating new ConfigEntry objects) may be why the integration is frequently deleting and recreating entities.

This is the part of this integration I've tried to wrap my head around but never have been able to :(

IoT-CI-Ltd commented 3 months ago

Hi, Just to chime in here with a "Mee too". I am in the process of moving from AgentDVR to BlueIRIS to see if the resource use is better (circa 20 camera's) I however came across this same error code when trying to integrate with HA.

Let me know if I can help test any fixes.

Thanks

AaronPower2035 commented 3 months ago

Just adding some information here that may help others having the same issue.

In the file /root/config/custom_components/blueiris/managers/config_flow_manager.py

About line 238 there is a function definition that appears to be missing a now mandatory option. I manually added a line as shown below, and then restart HA. After that, the Blue Iris integration completed its install and looks like it is working.

async def _update_entry(self): try: entry = ConfigEntry( version=0, minor_version=0, domain="", title="", data=self._data, source="", uniquie_id="", ### This is the line I added options=self._options, )

I don't have the skills to pull this apart properly and work out exactly what should be on that line, but setting something, even just a blank value appears to have worked. I was also going to try setting it to a GUID of some sort, but as it worked with a blank value, I've left it at that on my system.

Hopefully I haven't caused a time-bomb in the depths of HA :). Any feedback welcome.

kramttocs commented 3 months ago

Thanks @AaronPower2035 - please see my comment two posts above yours lol

I played around last night trying to change the logic to what HA really wants now (get rid of a lot of the manual work) but so far no luck. It really is what is needed though. Best bet may be to scavenge some of @elad-bar 's logic from the shinobi integration.

In the meantime, I'll release a version with the band-aid here in a bit just to get it back in a usable state.

kramttocs commented 3 months ago

The release with the fix is out there. Thanks all for your patience and have a good weekend!

Will close this but create a new wishlist ticket.