nielsfaber / alarmo

Easy to use alarm system integration for Home Assistant
1.31k stars 119 forks source link

Alarmo Fails to Load - 2021.8.6 #273

Closed sh00t2kill closed 2 years ago

sh00t2kill commented 3 years ago

2021-08-15 22:32:25 INFO (MainThread) [homeassistant.setup] Setting up alarmo 2021-08-15 22:32:25 INFO (MainThread) [homeassistant.setup] Setup of domain alarmo took 0.0 seconds 2021-08-15 22:32:31 INFO (MainThread) [homeassistant.helpers.storage] Migrating alarmo.storage storage from 2 to 4 2021-08-15 22:32:32 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Alarmo for alarmo File "/config/custom_components/alarmo/init.py", line 46, in async_setup_entry File "/config/custom_components/alarmo/store.py", line 596, in async_get_registry File "/config/custom_components/alarmo/store.py", line 591, in _load_reg File "/config/custom_components/alarmo/store.py", line 265, in async_load File "/config/custom_components/alarmo/store.py", line 236, in _async_migrate_func File "/config/custom_components/alarmo/store.py", line 242, in

nielsfaber commented 3 years ago

Could you add the rest of the error? I cannot see any description of the problem.

sh00t2kill commented 3 years ago

Rolling back to 1.6.2 resolves the issue.

Will see what logs i can find. I currently have debug logging turned on due to an unrelated issue, so theres a LOT

sh00t2kill commented 3 years ago

{ "log": "\u001bhomeassistant.config_entries [homeassistant.config_entries] Error setting up entry Alarmo for alarmo\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116348444Z" } { "log": "Traceback (most recent call last):\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116382545Z" } { "log": " File \"/usr/src/homeassistant/homeassistant/config_entries.py\", line 293, in async_setup\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116400095Z" } { "log": " result = await component.async_setup_entry(hass, self) # type: ignore\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116416946Z" } { "log": " File \"/config/custom_components/alarmo/init.py\", line 46, in async_setup_entry\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116434621Z" } { "log": " store = await async_get_registry(hass)\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116451321Z" } { "log": " File \"/config/custom_components/alarmo/store.py\", line 596, in async_get_registry\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116467584Z" } { "log": " return cast(AlarmoStorage, await task)\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116484022Z" } { "log": " File \"/config/custom_components/alarmo/store.py\", line 591, in _load_reg\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116499935Z" } { "log": " await registry.async_load()\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116516248Z" } { "log": " File \"/config/custom_components/alarmo/store.py\", line 265, in async_load\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116532211Z" } { "log": " data = await self._store.async_load()\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116548424Z" } { "log": " File \"/usr/src/homeassistant/homeassistant/helpers/storage.py\", line 108, in async_load\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116564524Z" } { "log": " return await self._load_task\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116580724Z" } { "log": " File \"/usr/src/homeassistant/homeassistant/helpers/storage.py\", line 113, in _async_load\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116596462Z" } { "log": " return await self._async_load_data()\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116612663Z" } { "log": " File \"/usr/src/homeassistant/homeassistant/helpers/storage.py\", line 142, in _async_load_data\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116629176Z" } { "log": " stored = await self._async_migrate_func(data[\"version\"], data[\"data\"])\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116704115Z" } { "log": " File \"/config/custom_components/alarmo/store.py\", line 236, in _async_migrate_func\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116740253Z" } { "log": " data[\"sensors\"] = [\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116757766Z" } { "log": " File \"/config/custom_components/alarmo/store.py\", line 242, in \u003clistcomp\u003e\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116774154Z" } { "log": " \"auto_bypass_modes\": sensor[\"modes\"] if sensor[\"auto_bypass\"] else [],\n", "stream": "stderr", "time": "2021-08-15T13:21:24.116791367Z" } { "log": "KeyError: 'auto_bypass'\u001b[0m\n", "stream": "stderr", "time": "2021-08-15T13:21:24.11680798Z" }

nielsfaber commented 3 years ago

Thanks for sharing!

It would be great if you could make some local change to test. If you could go into your custom_components/alarmo/store.py and edit line 242:

                        "auto_bypass_modes": sensor["modes"] if sensor["auto_bypass"] else [],

Change to:

                        "auto_bypass_modes": sensor["modes"] if "auto_bypass" in sensor and sensor["auto_bypass"] else [],

This should resolve the issue, but I have no means to test it (since for me it doesn't occur).

nielsfaber commented 3 years ago

Another option that comes to mind is staying in v1.6.2, making some change to alarmo (e.g. disabling a sensor), waiting 10 sec and trying the update to v1.7.1 again (requires restart of HA). The database format you have seems outdated (it looks like you came from an old version), this is updated by making a configuration change. There's a good chance this will also resolve the problem.

pr0fetul commented 3 years ago

Hi, Here is the error I receive when HA tries to load Alarmo:


Logger: homeassistant.config_entries
Source: custom_components/alarmo/store.py:242
Integration: Alarmo (documentation, issues)
First occurred: 2:24:32 PM (1 occurrences)
Last logged: 2:24:32 PM
Error setting up entry Alarmo for alarmo

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 293, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/config/custom_components/alarmo/__init__.py", line 46, in async_setup_entry
    store = await async_get_registry(hass)
  File "/config/custom_components/alarmo/store.py", line 596, in async_get_registry
    return cast(AlarmoStorage, await task)
  File "/config/custom_components/alarmo/store.py", line 591, in _load_reg
    await registry.async_load()
  File "/config/custom_components/alarmo/store.py", line 265, in async_load
    data = await self._store.async_load()
  File "/usr/src/homeassistant/homeassistant/helpers/storage.py", line 108, in async_load
    return await self._load_task
  File "/usr/src/homeassistant/homeassistant/helpers/storage.py", line 113, in _async_load
    return await self._async_load_data()
  File "/usr/src/homeassistant/homeassistant/helpers/storage.py", line 142, in _async_load_data
    stored = await self._async_migrate_func(data["version"], data["data"])
  File "/config/custom_components/alarmo/store.py", line 236, in _async_migrate_func
    data["sensors"] = [
  File "/config/custom_components/alarmo/store.py", line 242, in <listcomp>
    "auto_bypass_modes": sensor["modes"] if sensor["auto_bypass"] else [],
KeyError: 'auto_bypass'

I will try to change the code as advised and see if it works

pr0fetul commented 3 years ago

I can confirm that after changing the code - it works and Alarmo works now.

nielsfaber commented 3 years ago

@pr0fetul Thanks for reporting, I will work on a new release containing this fix.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days