mirror of
https://github.com/home-assistant/core.git
synced 2025-08-15 10:31:39 +02:00
migrate device tracker
This commit is contained in:
@@ -41,7 +41,7 @@ from homeassistant.const import (
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DOMAIN = 'device_tracker'
|
||||
DEPENDENCIES = ['zone']
|
||||
DEPENDENCIES = ['zone', 'group']
|
||||
|
||||
GROUP_NAME_ALL_DEVICES = 'all devices'
|
||||
ENTITY_ID_ALL_DEVICES = group.ENTITY_ID_FORMAT.format('all_devices')
|
||||
@@ -180,8 +180,6 @@ def async_setup(hass: HomeAssistantType, config: ConfigType):
|
||||
if setup_tasks:
|
||||
yield from asyncio.wait(setup_tasks, loop=hass.loop)
|
||||
|
||||
yield from tracker.async_setup_group()
|
||||
|
||||
@callback
|
||||
def async_device_tracker_discovered(service, info):
|
||||
"""Handle the discovery of device tracker platforms."""
|
||||
@@ -233,7 +231,6 @@ class DeviceTracker(object):
|
||||
self.mac_to_dev = {dev.mac: dev for dev in devices if dev.mac}
|
||||
self.consider_home = consider_home
|
||||
self.track_new = track_new
|
||||
self.group = None # type: group.Group
|
||||
self._is_updating = asyncio.Lock(loop=hass.loop)
|
||||
|
||||
for dev in devices:
|
||||
@@ -303,9 +300,9 @@ class DeviceTracker(object):
|
||||
})
|
||||
|
||||
# During init, we ignore the group
|
||||
if self.group is not None:
|
||||
yield from self.group.async_update_tracked_entity_ids(
|
||||
list(self.group.tracking) + [device.entity_id])
|
||||
self.group.async_set_group(
|
||||
self.hass, slugify(GROUP_NAME_ALL_DEVICES), visible=False,
|
||||
name=GROUP_NAME_ALL_DEVICES, delta=[device.entity_id])
|
||||
|
||||
# lookup mac vendor string to be stored in config
|
||||
yield from device.set_vendor_for_mac()
|
||||
|
@@ -137,11 +137,11 @@ def set_visibility(hass, entity_id=None, visible=True):
|
||||
|
||||
|
||||
def set_group(hass, object_id, name=None, entity_ids=None, visible=None,
|
||||
icon=None, view=None, control=None):
|
||||
icon=None, view=None, control=None, delta=None):
|
||||
"""Create a new user group."""
|
||||
hass.add_job(
|
||||
async_set_group, hass, object_id, name, entity_ids, visible, icon,
|
||||
view, control)
|
||||
view, control, delta)
|
||||
|
||||
|
||||
@callback
|
||||
@@ -157,6 +157,7 @@ def async_set_group(hass, object_id, name=None, entity_ids=None, visible=None,
|
||||
(ATTR_ICON, icon),
|
||||
(ATTR_VIEW, view),
|
||||
(ATTR_CONTROL, control),
|
||||
(ATTR_DELTA, delta),
|
||||
] if value is not None
|
||||
}
|
||||
|
||||
|
@@ -229,7 +229,7 @@ class EntityComponent(object):
|
||||
run_callback_threadsafe(
|
||||
self.hass.loop, self.async_update_group).result()
|
||||
|
||||
@asyncio.coroutine
|
||||
@callback
|
||||
def async_update_group(self):
|
||||
"""Set up and/or update component group.
|
||||
|
||||
@@ -370,7 +370,7 @@ class EntityPlatform(object):
|
||||
tasks = [async_process_entity(entity) for entity in new_entities]
|
||||
|
||||
yield from asyncio.wait(tasks, loop=self.component.hass.loop)
|
||||
yield from self.component.async_update_group()
|
||||
self.component.async_update_group()
|
||||
|
||||
if self._async_unsub_polling is not None or \
|
||||
not any(entity.should_poll for entity
|
||||
|
Reference in New Issue
Block a user