Skip to content

Commit

Permalink
Merge pull request #193 from Snuffy2/Add-zone-as-places-sensor-type
Browse files Browse the repository at this point in the history
Add zone as places tracker type
  • Loading branch information
Snuffy2 authored Aug 6, 2023
2 parents 08a1fa0 + 961e718 commit 44a3545
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions custom_components/places/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
str(Platform.DEVICE_TRACKER),
str("person"),
str(Platform.SENSOR),
CONF_ZONE,
"variable",
]
TRACKING_DOMAINS_NEED_LATLONG = [
Expand Down
13 changes: 8 additions & 5 deletions custom_components/places/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,9 @@ def is_float(self, value):

def in_zone(self):
if not self.is_attr_blank(ATTR_DEVICETRACKER_ZONE):
if (
if self.get_attr(CONF_DEVICETRACKER_ID).split(".")[0] == CONF_ZONE:
return False
elif (
"stationary" in self.get_attr(ATTR_DEVICETRACKER_ZONE).lower()
or self.get_attr(ATTR_DEVICETRACKER_ZONE).lower().startswith("statzon")
or self.get_attr(ATTR_DEVICETRACKER_ZONE)
Expand Down Expand Up @@ -800,10 +802,11 @@ def check_for_updated_entity_name(self):
)

def get_zone_details(self):
self.set_attr(
ATTR_DEVICETRACKER_ZONE,
self._hass.states.get(self.get_attr(CONF_DEVICETRACKER_ID)).state,
)
if self.get_attr(CONF_DEVICETRACKER_ID).split(".")[0] != CONF_ZONE:
self.set_attr(
ATTR_DEVICETRACKER_ZONE,
self._hass.states.get(self.get_attr(CONF_DEVICETRACKER_ID)).state,
)
if self.in_zone():
devicetracker_zone_name_state = None
devicetracker_zone_id = self._hass.states.get(
Expand Down

0 comments on commit 44a3545

Please sign in to comment.