Insteon devices dropping from ALDB and becoming 'unavailable'

It sounds like this might be the same thing @p0lar was reporting earlier in the year.

Devices that have been in place for a long time are working fine. New devices I’ve added lately (within last few months, after upgrade to HA v.111) are responding to the Insteon app but not to HA. They work once. Then on next HA reboot the devices become ‘unavailable’.

For a while, I could kick them back into operation by adding them in Insteon app. Since they already existed both in Insteon app and HA, they would keep their settings. It seemed like the process of adding the device would cause HA to see them again. But after most recent HA update (I’m on v.117.6 now), that stopped working and I can’t get them to be detected by HA at all now.

When I went through the ALDB, I found 6 devices not listed in the db that are in HA. Of those 6, 3 work and 3 are ‘unavailable’. All of them are new devices added after v.111 upgrade. All 6 work perfectly in Insteon iPhone app. All 6 are the devices added most recently. The 3 that work but are missing were

For one of the ‘unavailable’ devices, when I just tried (unsuccessfully) to add it in Insteon app, I get this in logs:

2020-11-13 16:03:01 INFO (MainThread) [pyinsteon.managers.device_manager] Adding device to INSTEON devices list: 536530
2020-11-13 16:03:01 DEBUG (MainThread) [homeassistant.components.insteon.utils] Adding new INSTEON device to Home Assistant with address 536530
2020-11-13 16:03:04 DEBUG (MainThread) [homeassistant.components.insteon.utils] Registering on/off event for 53.65.30 1 on_event
2020-11-13 16:03:04 DEBUG (MainThread) [homeassistant.components.insteon.utils] Registering on/off event for 53.65.30 1 off_event
2020-11-13 16:03:04 DEBUG (MainThread) [homeassistant.components.insteon.utils] Registering on/off event for 53.65.30 1 on_fast_event
2020-11-13 16:03:04 DEBUG (MainThread) [homeassistant.components.insteon.utils] Registering on/off event for 53.65.30 1 off_fast_event
2020-11-13 16:03:04 ERROR (MainThread) [homeassistant.components.switch] Error adding entities for domain switch with platform insteon
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 314, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in _async_add_entity
    device_info = entity.device_info
  File "/usr/src/homeassistant/homeassistant/components/insteon/insteon_entity.py", line 87, in device_info
    "model": f"{self._insteon_device.model} (0x{self._insteon_device.cat:02x}, 0x{self._insteon_device.subcat:02x})",
  File "/usr/local/lib/python3.8/enum.py", line 669, in __format__
    return cls.__format__(val, format_spec)
ValueError: Unknown format code 'x' for object of type 'str'
2020-11-13 16:03:08 INFO (MainThread) [pyinsteon.managers.device_manager] Adding device to INSTEON devices list: 536530
2020-11-13 16:03:08 DEBUG (MainThread) [homeassistant.components.insteon.utils] Adding new INSTEON device to Home Assistant with address 536530
2020-11-13 16:03:25 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/pyinsteon/managers/device_manager.py", line 222, in async_setup_device
    await device.async_add_default_links()
  File "/usr/local/lib/python3.8/site-packages/pyinsteon/device_types/device_base.py", line 224, in async_add_default_links
    return await async_add_default_links(self)
  File "/usr/local/lib/python3.8/site-packages/pyinsteon/managers/link_manager/default_links.py", line 39, in async_add_default_links
    result = await async_link_devices(
  File "/usr/local/lib/python3.8/site-packages/pyinsteon/managers/link_manager/__init__.py", line 52, in async_link_devices
    _, failed_1 = await controller.aldb.async_write()
  File "/usr/local/lib/python3.8/site-packages/pyinsteon/aldb/aldb_base.py", line 272, in async_write
    for mem_addr in self._dirty_records:
RuntimeError: dictionary changed size during iteration

So, it feels like two different problems.

  1. whatever those python errors are.
  2. why are new devices not persisting in the aldb?

@teharris1, is there a way to manually inject an entry into the aldb? Or, a way to pull the aldb from the hub and compare it to the HA copy?

Part of the issue resolved itself. I have no idea how.

I pulled out the set button to kill power to one of the devices that was missing in HA but working in Insteon app, and then left if without power. While it was off, I removed all mention of it from Insteon app and HA. The next day when I went to push the set button back in to turn it back on, I noticed the other two devices were present in HA and working perfectly. I did a factory reset on the one I was fiddling with and added it back into Insteon app and HA and it is working perfectly now, too. I didn’t touch the other two. They just sort of magically started working once the third one was gone for while. ¯\_(ツ)_/¯

I still have one switch (the one I just reset and left unpowered for a day) that was working for about a day and then went to ‘unavailable’ right as I was feeling confident that the issue was resolved.

When I tried to add it in Insteon app, I got this in HA:

2020-11-30 16:45:26 INFO (MainThread) [pyinsteon.managers.device_manager] Adding device to INSTEON devices list: 536530
2020-11-30 16:45:26 DEBUG (MainThread) [homeassistant.components.insteon.utils] Adding new INSTEON device to Home Assistant with address 536530
2020-11-30 16:45:30 DEBUG (MainThread) [homeassistant.components.insteon.utils] Registering on/off event for 53.65.30 1 on_event
2020-11-30 16:45:30 DEBUG (MainThread) [homeassistant.components.insteon.utils] Registering on/off event for 53.65.30 1 off_event
2020-11-30 16:45:30 DEBUG (MainThread) [homeassistant.components.insteon.utils] Registering on/off event for 53.65.30 1 on_fast_event
2020-11-30 16:45:30 DEBUG (MainThread) [homeassistant.components.insteon.utils] Registering on/off event for 53.65.30 1 off_fast_event
2020-11-30 16:45:30 ERROR (MainThread) [homeassistant.components.switch] Error adding entities for domain switch with platform insteon
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 316, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 384, in _async_add_entity
    device_info = entity.device_info
  File "/usr/src/homeassistant/homeassistant/components/insteon/insteon_entity.py", line 87, in device_info
    "model": f"{self._insteon_device.model} (0x{self._insteon_device.cat:02x}, 0x{self._insteon_device.subcat:02x})",
  File "/usr/local/lib/python3.8/enum.py", line 669, in __format__
    return cls.__format__(val, format_spec)
ValueError: Unknown format code 'x' for object of type 'str'
2020-11-30 16:45:30 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 316, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 384, in _async_add_entity
    device_info = entity.device_info
  File "/usr/src/homeassistant/homeassistant/components/insteon/insteon_entity.py", line 87, in device_info
    "model": f"{self._insteon_device.model} (0x{self._insteon_device.cat:02x}, 0x{self._insteon_device.subcat:02x})",
  File "/usr/local/lib/python3.8/enum.py", line 669, in __format__
    return cls.__format__(val, format_spec)
ValueError: Unknown format code 'x' for object of type 'str'
2020-11-30 16:45:34 INFO (MainThread) [pyinsteon.managers.device_manager] Adding device to INSTEON devices list: 536530
2020-11-30 16:45:34 DEBUG (MainThread) [homeassistant.components.insteon.utils] Adding new INSTEON device to Home Assistant with address 536530
2020-11-30 16:45:48 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/pyinsteon/managers/device_manager.py", line 222, in async_setup_device
    await device.async_add_default_links()
  File "/usr/local/lib/python3.8/site-packages/pyinsteon/device_types/device_base.py", line 224, in async_add_default_links
    return await async_add_default_links(self)
  File "/usr/local/lib/python3.8/site-packages/pyinsteon/managers/link_manager/default_links.py", line 39, in async_add_default_links
    result = await async_link_devices(
  File "/usr/local/lib/python3.8/site-packages/pyinsteon/managers/link_manager/__init__.py", line 52, in async_link_devices
    _, failed_1 = await controller.aldb.async_write()
  File "/usr/local/lib/python3.8/site-packages/pyinsteon/aldb/aldb_base.py", line 272, in async_write
    for mem_addr in self._dirty_records:
RuntimeError: dictionary changed size during iteration

If this happens again, there is an option to reset the Insteon integration in HA completely by deleting (or renaming) the config/insteon_device.json. That is where the integration keeps the ALDB info that it collects from the modem and the devices.

Hello,

I am having the same issue, some of the Insteon devices are working fine in HA and others are unavailable.

I had deleted the .json file and also factory resented on those devices.

After that the unavailable devices worked but soon I restarted the HA, the same devices became unavailable.

Can someone please direct to fix the problem.

Thanks in advance.

Hello, did you find a fix for your issue? I have the exact same thing.

Yup, new HA user here trying to get things set up and have one Insteon device (out of my first five) that is always unavailable. It did work for a couple days after I initially added it but now it’s just not available. I’ve tried restarting HA and the integration and it’s offline.

The device works fine in the Insteon app on my phone though so I’m not sure where the disconnect is.

Where can I see logs of the integration?

In configuration.yaml you can control the logging levels of various components. Put the insteon components in ‘debug’ and then watch the home-assistant.log file.

logger: 
  default: info
  logs:
    insteonplm: debug
    homeassistant.components.insteon: debug

_

Factory reset the finicky device. Then pull out the set button so it powers off. Leave it off for a while, long enough for insteon and HA to sync and update without seeing it. Then power it back up and set it up like it’s a new device. That’s how I got my uncooperative devices to start working. It was leaving it powered off for a while that was different from my prior attempts when it finally started working. Haven’t had a problem with that switch since.

To get my Insteon dual outlet working again, I deleted it from the devices on the app, then power cycled it via the breaker. Then I added it back in and waited for the sync (any idea how long that takes?) and it hasn’t had a problem since I did that.

Thanks for the debug info though, that’ll be helpful if it occurs again.