mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 18:27:51 +00:00
Setup device tracker group at end of init
This commit is contained in:
parent
81288cc988
commit
804b7669b7
@ -131,6 +131,8 @@ def setup(hass, config):
|
|||||||
tracker.update_stale(now)
|
tracker.update_stale(now)
|
||||||
track_utc_time_change(hass, update_stale, second=range(0, 60, 5))
|
track_utc_time_change(hass, update_stale, second=range(0, 60, 5))
|
||||||
|
|
||||||
|
tracker.setup_group()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@ -150,8 +152,7 @@ class DeviceTracker(object):
|
|||||||
entity_ids.append(device.entity_id)
|
entity_ids.append(device.entity_id)
|
||||||
device.update_ha_state()
|
device.update_ha_state()
|
||||||
|
|
||||||
self.group = group.setup_group(hass, GROUP_NAME_ALL_DEVICES,
|
self.group = None
|
||||||
entity_ids, False)
|
|
||||||
|
|
||||||
# pylint: disable=too-many-arguments
|
# pylint: disable=too-many-arguments
|
||||||
def see(self, mac=None, dev_id=None, host_name=None, location_name=None,
|
def see(self, mac=None, dev_id=None, host_name=None, location_name=None,
|
||||||
@ -187,10 +188,19 @@ class DeviceTracker(object):
|
|||||||
if device.track:
|
if device.track:
|
||||||
device.update_ha_state()
|
device.update_ha_state()
|
||||||
|
|
||||||
|
# During init, we ignore the group
|
||||||
|
if self.group is not None:
|
||||||
self.group.update_tracked_entity_ids(
|
self.group.update_tracked_entity_ids(
|
||||||
list(self.group.tracking) + [device.entity_id])
|
list(self.group.tracking) + [device.entity_id])
|
||||||
update_config(self.hass.config.path(YAML_DEVICES), dev_id, device)
|
update_config(self.hass.config.path(YAML_DEVICES), dev_id, device)
|
||||||
|
|
||||||
|
def setup_group(self):
|
||||||
|
""" Initializes group for all tracked devices. """
|
||||||
|
entity_ids = (dev.entity_id for dev in self.devices.values()
|
||||||
|
if dev.track)
|
||||||
|
self.group = group.setup_group(
|
||||||
|
self.hass, GROUP_NAME_ALL_DEVICES, entity_ids, False)
|
||||||
|
|
||||||
def update_stale(self, now):
|
def update_stale(self, now):
|
||||||
""" Update stale devices. """
|
""" Update stale devices. """
|
||||||
with self.lock:
|
with self.lock:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user