Skip to content

Commit

Permalink
Distinguish between shared/non-shared locations. (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
twrecked authored May 10, 2023
1 parent e81cd46 commit c21f898
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
0.8.0b7:
Distinguish between user/shared location.
Fix missing event issue.
Tidy capture code.
Specify Python 3
Expand Down
4 changes: 2 additions & 2 deletions pyaarlo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,9 @@ def _refresh_locations(self):
self.warning("No locations returned from " + url)
else:
for user_location in location_data.get("userLocations", []):
self._locations.append(ArloLocation(self, user_location))
self._locations.append(ArloLocation(self, user_location, True))
for shared_location in location_data.get("sharedLocations", []):
self._locations.append(ArloLocation(self, shared_location))
self._locations.append(ArloLocation(self, shared_location, False))

self.vdebug("locations={}".format(pprint.pformat(self._locations)))

Expand Down
11 changes: 9 additions & 2 deletions pyaarlo/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@
}


def location_name(name, user):
if user:
return f"user_location_{name}"
return f"location_{name}"


class ArloLocation(ArloSuper):
""" Represents a Location object.
Each Arlo account can have multiple owned locations and multiple shared locations.
"""
def __init__(self, arlo, attrs):
super().__init__(attrs.get("locationName", "unknown"), arlo, attrs,
def __init__(self, arlo, attrs, user=False):
super().__init__(location_name(attrs.get("locationName", "unknown"), user),
arlo, attrs,
id=attrs.get("locationId", "unknown"),
type="location")

Expand Down
4 changes: 4 additions & 0 deletions pyaarlo/super.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ def add_attr_callback(self, attr, cb):
with self._lock:
self._attr_cbs_.append((attr, cb))

@property
def state(self):
return "ok"

def debug(self, msg):
self._arlo.debug(f"{self._name}: {msg}")

Expand Down

0 comments on commit c21f898

Please sign in to comment.