Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions custom_components/keymaster/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,10 @@ async def _handle_lock_state_change(
if not event:
return

# Ignore events without a user_id - they're from zwave - let handle_zwave_js_lock_event handle it
if event.context.as_dict()["user_id"] is None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be event.data.get("user_id") ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user_id isn't part of the data member of the event? As far as I can tell, it's only part of the context, which is a separate member.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if event.context.as_dict()["user_id"] is None:
if event.context.get("user_id") is None:

then we can do this instead.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe we can - as far as I can tell, the context object does not implement a Dict interface directly. Which is why I did as_dict() to get a dict out of it. As far as I can tell, it implements basically NO API at all. https://github.com/home-assistant/core/blob/7eb0f2993f25deba1fba9e4dcbcc8d13cf574482/homeassistant/core.py#L1243 - perhaps directly fetching the member would work?

return

changed_entity: str = event.data["entity_id"]

# Don't do anything if the changed entity is not this lock
Expand Down
Loading