Skip to content

Commit

Permalink
feat: expose camera person status
Browse files Browse the repository at this point in the history
  • Loading branch information
adriencog committed Jul 14, 2024
1 parent f84c513 commit 22b8957
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/pyatmo/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ async def update(self, raw_data: RawData) -> None:
for room in data.get("rooms", []):
self.rooms[room["id"]].update(room)

for person_status in data.get("persons", []):
if person := self.persons.get(person_status["id"]):
person.update(person_status)

self.events = {
s["id"]: Event(home_id=self.entity_id, raw_data=s)
for s in data.get(EVENTS, [])
Expand Down
7 changes: 7 additions & 0 deletions src/pyatmo/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class Person(NetatmoBase):

pseudo: str | None
url: str | None
out_of_sight: bool | None
last_seen: int | None

def __init__(self, home: Home, raw_data: RawData) -> None:
"""Initialize a Netatmo person instance."""
Expand All @@ -29,3 +31,8 @@ def __init__(self, home: Home, raw_data: RawData) -> None:
self.home = home
self.pseudo = raw_data.get("pseudo")
self.url = raw_data.get("url")

def update(self, raw_data: RawData) -> None:
"""Update person data."""
self.out_of_sight = raw_data.get("out_of_sight")
self.last_seen = raw_data.get("last_seen")
5 changes: 4 additions & 1 deletion tests/test_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ async def test_async_camera_NACamera(async_home): # pylint: disable=invalid-nam
assert module.local_url == "http://192.168.0.123/678460a0d47e5618699fb31169e2b47d"
person_id = "91827374-7e04-5298-83ad-a0cb8372dff1"
assert person_id in module.home.persons
assert module.home.persons[person_id].pseudo == "John Doe"
person = module.home.persons[person_id]
assert person.pseudo == "John Doe"
assert person.out_of_sight
assert person.last_seen == 1557071156


@pytest.mark.asyncio
Expand Down

0 comments on commit 22b8957

Please sign in to comment.