Skip to content

Commit

Permalink
feat: add support for linked lock activities (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Sep 2, 2024
1 parent 43799e1 commit 5eed87b
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/fixtures/linked_lock_activity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"id": "0af6bd11-621b-4e32-b0ea-1d13804d31e7",
"timestamp": 1725061953081,
"icon": "https://d3osa7xy9vsc0q.cloudfront.net/app/ActivityFeedIcons/[email protected]",
"action": "linked_lock",
"deviceID": "X",
"deviceType": "lock",
"title": "<b>Front Door</b> locked by linked operation."
}
9 changes: 9 additions & 0 deletions tests/fixtures/linked_unlock_activity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"id": "74b5a4b6-8c89-4aac-8eb5-38b0350f4164",
"timestamp": 1725062446640,
"icon": "https://d3osa7xy9vsc0q.cloudfront.net/app/ActivityFeedIcons/[email protected]",
"action": "linked_unlock",
"deviceID": "x",
"deviceType": "lock",
"title": "<b>Front Door</b> unlocked by linked operation."
}
40 changes: 40 additions & 0 deletions tests/test_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

from yalexs.activity import (
ACTION_BRIDGE_OFFLINE,
ACTION_LINKED_LOCK,
ACTION_LINKED_UNLOCK,
ACTION_BRIDGE_ONLINE,
ACTION_DOOR_CLOSE_2,
ACTION_DOOR_CLOSED,
Expand Down Expand Up @@ -140,6 +142,8 @@ def test_activity_actions(self):
ACTION_LOCK_MANUAL_LOCK,
ACTION_LOCK_MANUAL_UNLATCH,
ACTION_LOCK_MANUAL_UNLOCK,
ACTION_LINKED_LOCK,
ACTION_LINKED_UNLOCK,
],
)
self.assertCountEqual(
Expand Down Expand Up @@ -506,3 +510,39 @@ def test_websocket_activity(self):
)
assert manual_unlock_activity.source == SOURCE_WEBSOCKET
assert manual_unlock_activity.was_pushed is True

def test_linked_unlock_activity_v4(self):
manual_lock_activity = LockOperationActivity(
SOURCE_LOG, json.loads(load_fixture("linked_unlock_activity.json"))
)
assert manual_lock_activity.operated_by == "Linked Unlock"
assert manual_lock_activity.operated_remote is False
assert manual_lock_activity.operated_keypad is False
assert manual_lock_activity.operated_manual is False
assert manual_lock_activity.operated_tag is False
assert (
manual_lock_activity.operator_image_url
== "https://d3osa7xy9vsc0q.cloudfront.net/app/ActivityFeedIcons/[email protected]"
)
assert (
manual_lock_activity.operator_thumbnail_url
== "https://d3osa7xy9vsc0q.cloudfront.net/app/ActivityFeedIcons/[email protected]"
)

def test_linked_lock_activity_v4(self):
manual_lock_activity = LockOperationActivity(
SOURCE_LOG, json.loads(load_fixture("linked_lock_activity.json"))
)
assert manual_lock_activity.operated_by == "Linked Lock"
assert manual_lock_activity.operated_remote is False
assert manual_lock_activity.operated_keypad is False
assert manual_lock_activity.operated_manual is False
assert manual_lock_activity.operated_tag is False
assert (
manual_lock_activity.operator_image_url
== "https://d3osa7xy9vsc0q.cloudfront.net/app/ActivityFeedIcons/[email protected]"
)
assert (
manual_lock_activity.operator_thumbnail_url
== "https://d3osa7xy9vsc0q.cloudfront.net/app/ActivityFeedIcons/[email protected]"
)
8 changes: 8 additions & 0 deletions yalexs/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
ACTION_HOMEKEY_LOCK = "homekey_lock"
ACTION_HOMEKEY_UNLATCH = "homekey_unlatch"
ACTION_HOMEKEY_UNLOCK = "homekey_unlock"
ACTION_LINKED_LOCK = "linked_lock"
ACTION_LINKED_UNLOCK = "linked_unlock"

ACTION_DOOR_OPEN = "dooropen"
ACTION_DOOR_OPEN_2 = "door_open"
Expand Down Expand Up @@ -75,6 +77,8 @@
ACTION_HOMEKEY_LOCK,
ACTION_HOMEKEY_UNLATCH,
ACTION_HOMEKEY_UNLOCK,
ACTION_LINKED_LOCK,
ACTION_LINKED_UNLOCK,
ACTION_LOCK_AUTO_LOCK,
ACTION_LOCK_ONETOUCHLOCK,
ACTION_LOCK_ONETOUCHLOCK_2,
Expand Down Expand Up @@ -107,6 +111,8 @@
ACTION_HOMEKEY_LOCK: ("Homekey", "Lock"),
ACTION_HOMEKEY_UNLATCH: ("Homekey", "Unlatch"),
ACTION_HOMEKEY_UNLOCK: ("Homekey", "Unlock"),
ACTION_LINKED_LOCK: ("Linked", "Lock"),
ACTION_LINKED_UNLOCK: ("Linked", "Unlock"),
ACTION_LOCK_AUTO_LOCK: ("Auto", "Lock"),
ACTION_LOCK_ONETOUCHLOCK: ("One-Touch", "Lock"),
ACTION_LOCK_ONETOUCHLOCK_2: ("One-Touch", "Lock"),
Expand Down Expand Up @@ -161,6 +167,8 @@
ACTION_RF_UNLATCH: LockStatus.UNLATCHED,
ACTION_RF_UNLOCK: LockStatus.UNLOCKED,
ACTION_HOMEKEY_LOCK: LockStatus.LOCKED,
ACTION_LINKED_LOCK: LockStatus.LOCKED,
ACTION_LINKED_UNLOCK: LockStatus.UNLOCKED,
ACTION_HOMEKEY_UNLATCH: LockStatus.UNLATCHED,
ACTION_HOMEKEY_UNLOCK: LockStatus.UNLOCKED,
ACTION_LOCK_AUTO_LOCK: LockStatus.LOCKED,
Expand Down

0 comments on commit 5eed87b

Please sign in to comment.