Skip to content

Commit 087d9d3

Browse files
chemelli74frenck
authored andcommitted
Avoid cleanup/recreate of device_trackers not linked to a device for Vodafone Station (home-assistant#151904)
1 parent f07890c commit 087d9d3

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

homeassistant/components/vodafone_station/coordinator.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
from aiohttp import ClientSession
99
from aiovodafone import VodafoneStationDevice, VodafoneStationSercommApi, exceptions
1010

11-
from homeassistant.components.device_tracker import DEFAULT_CONSIDER_HOME
11+
from homeassistant.components.device_tracker import (
12+
DEFAULT_CONSIDER_HOME,
13+
DOMAIN as DEVICE_TRACKER_DOMAIN,
14+
)
1215
from homeassistant.config_entries import ConfigEntry
1316
from homeassistant.core import HomeAssistant
1417
from homeassistant.exceptions import ConfigEntryAuthFailed
15-
from homeassistant.helpers import device_registry as dr
18+
from homeassistant.helpers import entity_registry as er
1619
from homeassistant.helpers.device_registry import DeviceInfo
1720
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
1821
from homeassistant.util import dt as dt_util
@@ -71,16 +74,14 @@ def __init__(
7174
update_interval=timedelta(seconds=SCAN_INTERVAL),
7275
config_entry=config_entry,
7376
)
74-
device_reg = dr.async_get(self.hass)
75-
device_list = dr.async_entries_for_config_entry(
76-
device_reg, self.config_entry.entry_id
77-
)
7877

78+
entity_reg = er.async_get(hass)
7979
self.previous_devices = {
80-
connection[1].upper()
81-
for device in device_list
82-
for connection in device.connections
83-
if connection[0] == dr.CONNECTION_NETWORK_MAC
80+
entry.unique_id
81+
for entry in er.async_entries_for_config_entry(
82+
entity_reg, config_entry.entry_id
83+
)
84+
if entry.domain == DEVICE_TRACKER_DOMAIN
8485
}
8586

8687
def _calculate_update_time_and_consider_home(

0 commit comments

Comments
 (0)