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

feat: expose camera person status #502

Merged
Merged
Show file tree
Hide file tree
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 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)
cgtobi marked this conversation as resolved.
Show resolved Hide resolved

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 = None
last_seen: int | None = 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")
cgtobi marked this conversation as resolved.
Show resolved Hide resolved
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
cgtobi marked this conversation as resolved.
Show resolved Hide resolved
assert person.last_seen == 1557071156
cgtobi marked this conversation as resolved.
Show resolved Hide resolved
cgtobi marked this conversation as resolved.
Show resolved Hide resolved


@pytest.mark.asyncio
Expand Down