From ba99451244d6af5d9d475cbf7cba41259ab2fb9c Mon Sep 17 00:00:00 2001 From: tomaae <23486452+tomaae@users.noreply.github.com> Date: Mon, 14 Dec 2020 15:25:00 +0100 Subject: [PATCH] Hide non-existing hardware specific system sensors #73 --- custom_components/mikrotik_router/sensor.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/custom_components/mikrotik_router/sensor.py b/custom_components/mikrotik_router/sensor.py index df6f7ec..6b66455 100644 --- a/custom_components/mikrotik_router/sensor.py +++ b/custom_components/mikrotik_router/sensor.py @@ -194,6 +194,13 @@ def update_items(inst, config_entry, mikrotik_controller, async_add_entities, se for sensor in SENSOR_TYPES: if "system_" in sensor: + if ( + mikrotik_controller.data[SENSOR_TYPES[sensor][ATTR_PATH]][ + SENSOR_TYPES[sensor][ATTR_ATTR] + ] + == "unknown" + ): + continue item_id = f"{inst}-{sensor}" _LOGGER.debug("Updating sensor %s", item_id) if item_id in sensors: