Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running scenes gives unknown device ID error #345

Closed
jpoole412 opened this issue Nov 2, 2023 · 12 comments
Closed

Running scenes gives unknown device ID error #345

jpoole412 opened this issue Nov 2, 2023 · 12 comments
Labels
bug Something isn't working

Comments

@jpoole412
Copy link

Describe the bug
Running a scene often times gives an unknown device ID error. The device does show up correctly.

This error originated from a custom integration.

Logger: homeassistant
Source: custom_components/alarmdotcom/base_device.py:198
Integration: Alarm.com (documentation, issues)
First occurred: 9:37:39 AM (11 occurrences)
Last logged: 9:43:30 AM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/pyalarmdotcomajax/devices/registry.py", line 299, in get
return self._devices[device_id]
~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 10294121

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 233, in _handle_refresh_interval
await self._async_refresh(log_failures=True, scheduled=True)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 389, in _async_refresh
self.async_update_listeners()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 172, in async_update_listeners
update_callback()
File "/config/custom_components/alarmdotcom/base_device.py", line 91, in _handle_coordinator_update
super()._handle_coordinator_update()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 469, in _handle_coordinator_update
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 743, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 843, in _async_write_ha_state
state, attr = self._async_generate_attributes()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 787, in _async_generate_attributes
attr.update(self.extra_state_attributes or {})
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/alarmdotcom/base_device.py", line 198, in extra_state_attributes
raw = self._controller.api.devices.get(self._adc_id).raw_attributes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pyalarmdotcomajax/devices/registry.py", line 301, in get
raise UnkonwnDevice(device_id) from err
pyalarmdotcomajax.exceptions.UnkonwnDevice: Unknown device ID '10294121'.

To Reproduce
Clicking 'Activate' on a scene.

Expected behavior
Running the scene.

Home Assistant Version:
2023.11.0

Additional context

@jpoole412 jpoole412 added the bug Something isn't working label Nov 2, 2023
@lutzky
Copy link

lutzky commented Nov 3, 2023

This is occurring for me as well, but all the time, rather than just when running a scene. One example effect is that it causes the alarm state not to be fetched: e.g. when I turn off the alarm through the alarm.com app, it stays marked as "armed". When I then arm it from homeassistant, it does get armed (alarm.com app sees that), but homeassistant doesn't know that (still shows disarmed).

I think this used to happen rarely, and cause delays in homeassistant updating; but now it seems to happen almost all the time. This makes me wondering whether we're hitting some kind of rate-limiting on the alarm.com server.

That being said, the ID for my "UnkonwnDevice" (sic) is 10726749; when using the Web UI, the call to https://www.alarm.com/web/api/settings/manageDevices/deviceCatalogs/6785477 only has IDs of the form 96747708-\d+.

It would be super helpful if we could get the exception to dump the entire page payload that it's looking at to try and understand what's going on. Also perhaps a dump of whatever device IDs pyalarmdotcom is holding?

@mikesalz
Copy link

mikesalz commented Nov 4, 2023

Same here. I just updated from 2023.10.x to 2023.11.1. I don't THINK this was happening before; I think it is new with 2023.11. But it is really blowing up my logs.


Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/pyalarmdotcomajax/devices/registry.py", line 299, in get
    return self._devices[device_id]
           ~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 11927967

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 233, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 389, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 172, in async_update_listeners
    update_callback()
  File "/config/custom_components/alarmdotcom/base_device.py", line 91, in _handle_coordinator_update
    super()._handle_coordinator_update()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 469, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 743, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 843, in _async_write_ha_state
    state, attr = self._async_generate_attributes()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 787, in _async_generate_attributes
    attr.update(self.extra_state_attributes or {})
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alarmdotcom/base_device.py", line 198, in extra_state_attributes
    raw = self._controller.api.devices.get(self._adc_id).raw_attributes
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyalarmdotcomajax/devices/registry.py", line 301, in get
    raise UnkonwnDevice(device_id) from err
pyalarmdotcomajax.exceptions.UnkonwnDevice: Unknown device ID '11927967'.

@mikesalz
Copy link

mikesalz commented Nov 4, 2023

More info... For me, this seems to be isolated to v3.0.10. I reverted to v3.0.9 and the error is gone.

@lutzky
Copy link

lutzky commented Nov 5, 2023

Can confirm I'm not getting the log messages with v3.0.9. There's still a significant delay (2 minutes?) between turning the alarm on and having homeassistant realize that it's on (alarm.com finds out immediately), so I'm still not convinced what's going on.

@thomasshawn
Copy link

I had requested scenes. I see that it was implemented but I can't find them as an option. I still have the same choices I've always had, did I miss a checkbox somewhere to enable it?

@thomasshawn
Copy link

think i found it outside the integration but inside the HA scenes folder but I also get

**Failed to call service scene/turn_on. Unknown device ID '26155923'.
**

@mikesalz
Copy link

@elahd It looks like there were some issues with v3.0.10 and quite a few people had to roll back to the previous version. Just curious if you have had a chance to look into it and what your thoughts are? Thanks!

@elahd
Copy link
Collaborator

elahd commented Nov 18, 2023

I just released 3.0.11, which is a re-release of 3.0.9. This is in interim solution to stopping those log messages. The code base has become too messy since I rolled out WebSocket support and started chasing session timeout issues. I'm working on a refactor that I'll release as a beta in a week or so.

With that said, I won't ever be able to fix the lag that exists between a sensor triggering and the action being reported via API. Alarm.com has server-side logic that delays state reporting and that prevents a sensor from reporting the same status more than once in a 3 min period. The same delays exist on their own website and app.

@lutzky
Copy link

lutzky commented Nov 18, 2023

Thanks for working on this!

About the delay, it definitely seems like the app notices the state change long before homeassistant does. For example, when arming the alarm, within a couple of seconds I usually get a notification from the alarm.com app, and checking the app shows the alarm is armed; it takes homeassistant a few more minutes to notice (more than 3, I think, but less than 10 for sure). I think this is worse with 3.0.10 compared to 3.0.9, presumably because some of those polls are failing, so the status only updates on the next successful poll.

@mikesalz
Copy link

I just released 3.0.11

Thanks, but I think something went wrong with the tag. When I updated in HA, it went back to 3.0.10 rather than 3.0.11. Then I went to the repo and noticed the "v" was missing from .11. So maybe it still thinks 3.0.10 is the latest.

image

@adamantivm
Copy link

adamantivm commented Jan 6, 2024

Just to add myself to the list of people who are having this issue and wish it gone.
I get the folloing log entry every few seconds:

2024-01-06 19:48:46.314 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/pyalarmdotcomajax/devices/registry.py", line 299, in get
    return self._devices[device_id]
           ~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 37279686

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 243, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 399, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 182, in async_update_listeners
    update_callback()
  File "/config/custom_components/alarmdotcom/base_device.py", line 91, in _handle_coordinator_update
    super()._handle_coordinator_update()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 479, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 745, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 845, in _async_write_ha_state
    state, attr = self._async_generate_attributes()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 789, in _async_generate_attributes
    attr.update(self.extra_state_attributes or {})
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alarmdotcom/base_device.py", line 198, in extra_state_attributes
    raw = self._controller.api.devices.get(self._adc_id).raw_attributes
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyalarmdotcomajax/devices/registry.py", line 301, in get
    raise UnkonwnDevice(device_id) from err
pyalarmdotcomajax.exceptions.UnkonwnDevice: Unknown device ID '37279686'.

Update: I'm on the 3.0.10 version of the integration

@elahd
Copy link
Collaborator

elahd commented Jan 21, 2024

This is fixed in v3.0.12.

@elahd elahd closed this as completed Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants