mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-06-26 10:48:41 +02:00
fixed sensor exceptions in model
This commit is contained in:
parent
36a372db1f
commit
e8dde3bb52
1 changed files with 19 additions and 6 deletions
|
@ -15,6 +15,8 @@ from .const import (
|
||||||
DEFAULT_SENSOR_PORT_TRAFFIC,
|
DEFAULT_SENSOR_PORT_TRAFFIC,
|
||||||
CONF_TRACK_HOSTS,
|
CONF_TRACK_HOSTS,
|
||||||
DEFAULT_TRACK_HOSTS,
|
DEFAULT_TRACK_HOSTS,
|
||||||
|
CONF_SENSOR_PORT_TRACKER,
|
||||||
|
DEFAULT_SENSOR_PORT_TRACKER,
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER = getLogger(__name__)
|
_LOGGER = getLogger(__name__)
|
||||||
|
@ -103,8 +105,11 @@ def model_update_items(
|
||||||
new_sensors.append(sensors[item_id])
|
new_sensors.append(sensors[item_id])
|
||||||
else:
|
else:
|
||||||
# Sensors
|
# Sensors
|
||||||
if sensor.startswith("traffic_") and not config_entry.options.get(
|
if (
|
||||||
CONF_SENSOR_PORT_TRAFFIC, DEFAULT_SENSOR_PORT_TRAFFIC
|
uid_sensor.func == "MikrotikInterfaceTrafficSensor"
|
||||||
|
and not config_entry.options.get(
|
||||||
|
CONF_SENSOR_PORT_TRAFFIC, DEFAULT_SENSOR_PORT_TRAFFIC
|
||||||
|
)
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -113,28 +118,36 @@ def model_update_items(
|
||||||
|
|
||||||
# Sensors
|
# Sensors
|
||||||
if (
|
if (
|
||||||
uid_sensor.data_path == "interface"
|
uid_sensor.func == "MikrotikInterfaceTrafficSensor"
|
||||||
and uid_data[uid]["type"] == "bridge"
|
and uid_data[uid]["type"] == "bridge"
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if (
|
if (
|
||||||
uid_sensor.data_path == "client_traffic"
|
uid_sensor.func == "MikrotikClientTrafficSensor"
|
||||||
and uid_sensor.data_attribute not in uid_data[uid].keys()
|
and uid_sensor.data_attribute not in uid_data[uid].keys()
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Binary sensors
|
# Binary sensors
|
||||||
if (
|
if (
|
||||||
uid_sensor.data_path == "interface"
|
uid_sensor.func == "MikrotikPortBinarySensor"
|
||||||
and uid_data[uid]["type"] == "wlan"
|
and uid_data[uid]["type"] == "wlan"
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if (
|
||||||
|
uid_sensor.func == "MikrotikPortBinarySensor"
|
||||||
|
and not config_entry.options.get(
|
||||||
|
CONF_SENSOR_PORT_TRACKER, DEFAULT_SENSOR_PORT_TRACKER
|
||||||
|
)
|
||||||
|
):
|
||||||
|
continue
|
||||||
|
|
||||||
# Device Tracker
|
# Device Tracker
|
||||||
if (
|
if (
|
||||||
# Skip if host tracking is disabled
|
# Skip if host tracking is disabled
|
||||||
sensor == "host"
|
uid_sensor.func == "MikrotikHostDeviceTracker"
|
||||||
and not config_entry.options.get(
|
and not config_entry.options.get(
|
||||||
CONF_TRACK_HOSTS, DEFAULT_TRACK_HOSTS
|
CONF_TRACK_HOSTS, DEFAULT_TRACK_HOSTS
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue