Entity Component to no longer generate automatic groups (#23789)

This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2020-01-07 17:30:53 +01:00
1 parent 13e6479b6e
commit 9aa02e35a7
41 files changed
+149 -377

No files matched your search

@@ -8,15 +8,6 @@ import voluptuous as vol
from homeassistant import util
from homeassistant.components import zone
from homeassistant.components.group import (
ATTR_ADD_ENTITIES,
ATTR_ENTITIES,
ATTR_OBJECT_ID,
ATTR_VISIBLE,
DOMAIN as DOMAIN_GROUP,
SERVICE_SET,
)
from homeassistant.components.zone import async_active_zone
from homeassistant.config import async_log_exception, load_yaml_config_file
from homeassistant.const import (
ATTR_ENTITY_ID,
@@ -60,7 +51,6 @@ from .const import (
)
YAML_DEVICES = "known_devices.yaml"
GROUP_NAME_ALL_DEVICES = "all devices"
EVENT_NEW_DEVICE = "device_tracker_new_device"
@@ -104,7 +94,6 @@ class DeviceTracker:
else defaults.get(CONF_TRACK_NEW, DEFAULT_TRACK_NEW)
)
self.defaults = defaults
self.group = None
self._is_updating = asyncio.Lock()
for dev in devices:
@@ -230,21 +219,6 @@ class DeviceTracker:
if device.track:
await device.async_update_ha_state()
# During init, we ignore the group
if self.group and self.track_new:
self.hass.async_create_task(
self.hass.async_call(
DOMAIN_GROUP,
SERVICE_SET,
{
ATTR_OBJECT_ID: util.slugify(GROUP_NAME_ALL_DEVICES),
ATTR_VISIBLE: False,
ATTR_NAME: GROUP_NAME_ALL_DEVICES,
ATTR_ADD_ENTITIES: [device.entity_id],
},
)
)
self.hass.bus.async_fire(
EVENT_NEW_DEVICE,
{
@@ -271,27 +245,6 @@ class DeviceTracker:
update_config, self.hass.config.path(YAML_DEVICES), dev_id, device
)
@callback
def async_setup_group(self):
"""Initialize group for all tracked devices.
This method must be run in the event loop.
"""
entity_ids = [dev.entity_id for dev in self.devices.values() if dev.track]
self.hass.async_create_task(
self.hass.services.async_call(
DOMAIN_GROUP,
SERVICE_SET,
{
ATTR_OBJECT_ID: util.slugify(GROUP_NAME_ALL_DEVICES),
ATTR_VISIBLE: False,
ATTR_NAME: GROUP_NAME_ALL_DEVICES,
ATTR_ENTITIES: entity_ids,
},
)
)
@callback
def async_update_stale(self, now: dt_util.dt.datetime):
"""Update stale devices.
@@ -489,7 +442,7 @@ class Device(RestoreEntity):
if self.location_name:
self._state = self.location_name
elif self.gps is not None and self.source_type == SOURCE_TYPE_GPS:
zone_state = async_active_zone(
zone_state = zone.async_active_zone(
self.hass, self.gps[0], self.gps[1], self.gps_accuracy
)
if zone_state is None: