UniFi - use entity registry disabled_by to control available entities (#26141)
* Move ignoring logic to entity registry enabled default * Handle config to option import better * Properly enable and disable entity registry entries on changes from config entry options * Fix balloobs comments * Fix some tests * Fix tests * Simplify updating disable on entities * Simplify device tracker update function * Local entity disabled replaced on rebase * Only alter entities with changed options * Proper tracking of changed options * Back to straightforward updating of disabled
This commit is contained in:
1 parent
922522b089
commit
d9ef92f6d2
7 files changed
+172
-105
No files matched your search
@@ -15,6 +15,8 @@ from homeassistant.components.unifi.const import (
|
||||
CONF_CONTROLLER,
|
||||
CONF_SITE_ID,
|
||||
CONF_SSID_FILTER,
|
||||
CONF_TRACK_DEVICES,
|
||||
CONF_TRACK_WIRED_CLIENTS,
|
||||
UNIFI_CONFIG,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
@@ -69,10 +71,10 @@ DEVICE_1 = {
|
||||
"mac": "00:00:00:00:01:01",
|
||||
"model": "US16P150",
|
||||
"name": "device_1",
|
||||
"overheating": False,
|
||||
"overheating": True,
|
||||
"state": 1,
|
||||
"type": "usw",
|
||||
"upgradable": False,
|
||||
"upgradable": True,
|
||||
"version": "4.0.42.10433",
|
||||
}
|
||||
DEVICE_2 = {
|
||||
@@ -149,6 +151,7 @@ async def setup_controller(hass, mock_controller, options={}):
|
||||
system_options={},
|
||||
options=options,
|
||||
)
|
||||
hass.config_entries._entries.append(config_entry)
|
||||
mock_controller.config_entry = config_entry
|
||||
|
||||
await mock_controller.async_update()
|
||||
@@ -230,6 +233,25 @@ async def test_tracked_devices(hass, mock_controller):
|
||||
device_1 = hass.states.get("device_tracker.device_1")
|
||||
assert device_1.state == STATE_UNAVAILABLE
|
||||
|
||||
mock_controller.config_entry.add_update_listener(
|
||||
mock_controller.async_options_updated
|
||||
)
|
||||
hass.config_entries.async_update_entry(
|
||||
mock_controller.config_entry,
|
||||
options={
|
||||
CONF_SSID_FILTER: [],
|
||||
CONF_TRACK_WIRED_CLIENTS: False,
|
||||
CONF_TRACK_DEVICES: False,
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
client_1 = hass.states.get("device_tracker.client_1")
|
||||
assert client_1
|
||||
client_2 = hass.states.get("device_tracker.wired_client")
|
||||
assert client_2 is None
|
||||
device_1 = hass.states.get("device_tracker.device_1")
|
||||
assert device_1 is None
|
||||
|
||||
|
||||
async def test_restoring_client(hass, mock_controller):
|
||||
"""Test the update_items function with some clients."""
|
||||
|
||||
Reference in new issue
Block a user