Options to not track wired clients (#25669)
parent
a54ade1189
commit
93dfd613aa
|
@ -13,6 +13,7 @@ from .const import (
|
|||
CONF_DETECTION_TIME,
|
||||
CONF_DONT_TRACK_CLIENTS,
|
||||
CONF_DONT_TRACK_DEVICES,
|
||||
CONF_DONT_TRACK_WIRED_CLIENTS,
|
||||
CONF_SITE_ID,
|
||||
CONF_SSID_FILTER,
|
||||
CONTROLLER_ID,
|
||||
|
@ -32,6 +33,7 @@ CONTROLLER_SCHEMA = vol.Schema(
|
|||
),
|
||||
vol.Optional(CONF_DONT_TRACK_CLIENTS): cv.boolean,
|
||||
vol.Optional(CONF_DONT_TRACK_DEVICES): cv.boolean,
|
||||
vol.Optional(CONF_DONT_TRACK_WIRED_CLIENTS): cv.boolean,
|
||||
vol.Optional(CONF_DETECTION_TIME): vol.All(
|
||||
cv.time_period, cv.positive_timedelta
|
||||
),
|
||||
|
|
|
@ -15,6 +15,7 @@ CONF_BLOCK_CLIENT = "block_client"
|
|||
CONF_DETECTION_TIME = "detection_time"
|
||||
CONF_DONT_TRACK_CLIENTS = "dont_track_clients"
|
||||
CONF_DONT_TRACK_DEVICES = "dont_track_devices"
|
||||
CONF_DONT_TRACK_WIRED_CLIENTS = "dont_track_wired_clients"
|
||||
CONF_SSID_FILTER = "ssid_filter"
|
||||
|
||||
ATTR_MANUFACTURER = "Ubiquiti Networks"
|
||||
|
|
|
@ -30,6 +30,7 @@ from .const import (
|
|||
CONF_DETECTION_TIME,
|
||||
CONF_DONT_TRACK_CLIENTS,
|
||||
CONF_DONT_TRACK_DEVICES,
|
||||
CONF_DONT_TRACK_WIRED_CLIENTS,
|
||||
CONF_SITE_ID,
|
||||
CONF_SSID_FILTER,
|
||||
CONTROLLER_ID,
|
||||
|
@ -178,6 +179,12 @@ def update_items(controller, async_add_entities, tracked):
|
|||
):
|
||||
continue
|
||||
|
||||
if (
|
||||
controller.unifi_config.get(CONF_DONT_TRACK_WIRED_CLIENTS, False)
|
||||
and client.is_wired
|
||||
):
|
||||
continue
|
||||
|
||||
tracked[client_id] = UniFiClientTracker(client, controller)
|
||||
new_tracked.append(tracked[client_id])
|
||||
LOGGER.debug(
|
||||
|
|
|
@ -280,3 +280,21 @@ async def test_dont_track_devices(hass, mock_controller):
|
|||
|
||||
device_1 = hass.states.get("device_tracker.device_1")
|
||||
assert device_1 is None
|
||||
|
||||
|
||||
async def test_dont_track_wired_clients(hass, mock_controller):
|
||||
"""Test dont track wired clients config works."""
|
||||
mock_controller.mock_client_responses.append([CLIENT_1, CLIENT_2])
|
||||
mock_controller.mock_device_responses.append({})
|
||||
mock_controller.unifi_config = {unifi.CONF_DONT_TRACK_WIRED_CLIENTS: True}
|
||||
|
||||
await setup_controller(hass, mock_controller)
|
||||
assert len(mock_controller.mock_requests) == 2
|
||||
assert len(hass.states.async_all()) == 3
|
||||
|
||||
client_1 = hass.states.get("device_tracker.client_1")
|
||||
assert client_1 is not None
|
||||
assert client_1.state == "not_home"
|
||||
|
||||
client_2 = hass.states.get("device_tracker.client_2")
|
||||
assert client_2 is None
|
||||
|
|
Loading…
Reference in New Issue