From 2786ed6d3f236d8922dd64bc1b82a8fe01912964 Mon Sep 17 00:00:00 2001 From: tomaae <23486452+tomaae@users.noreply.github.com> Date: Sat, 12 Dec 2020 12:08:49 +0100 Subject: [PATCH] Sensor port tracker selection #68 --- custom_components/mikrotik_router/device_tracker.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/custom_components/mikrotik_router/device_tracker.py b/custom_components/mikrotik_router/device_tracker.py index 79f6b8e..eaa0aea 100644 --- a/custom_components/mikrotik_router/device_tracker.py +++ b/custom_components/mikrotik_router/device_tracker.py @@ -22,6 +22,8 @@ from .const import ( DEFAULT_TRACK_HOSTS, CONF_TRACK_HOSTS_TIMEOUT, DEFAULT_TRACK_HOST_TIMEOUT, + CONF_SENSOR_PORT_TRACKER, + DEFAULT_SENSOR_PORT_TRACKER, ) _LOGGER = logging.getLogger(__name__) @@ -123,6 +125,14 @@ def update_items(inst, config_entry, mikrotik_controller, async_add_entities, tr # Tracker function [MikrotikControllerPortDeviceTracker, MikrotikControllerHostDeviceTracker], ): + if ( + sid_func == MikrotikControllerPortDeviceTracker + and not config_entry.options.get( + CONF_SENSOR_PORT_TRACKER, DEFAULT_SENSOR_PORT_TRACKER + ) + ): + continue + for uid in mikrotik_controller.data[sid]: if ( # Skip if interface is wlan