diff --git a/custom_components/mikrotik_router/mikrotik_controller.py b/custom_components/mikrotik_router/mikrotik_controller.py index 07d1925..c889bdb 100644 --- a/custom_components/mikrotik_router/mikrotik_controller.py +++ b/custom_components/mikrotik_router/mikrotik_controller.py @@ -1303,6 +1303,8 @@ class MikrotikControllerData: ensure_vals=[ {"name": "uptime", "default": 0}, {"name": "uptime_epoch", "default": 0}, + {"name": "clients_wired", "default": 0}, + {"name": "clients_wireless", "default": 0}, ], ) @@ -1804,6 +1806,8 @@ class MikrotikControllerData: await self.async_ping_tracked_hosts(utcnow()) # Process hosts + self.data["resource"]["clients_wired"] = 0 + self.data["resource"]["clients_wireless"] = 0 for uid, vals in self.data["host"].items(): # CAPS-MAN availability if vals["source"] == "capsman" and uid not in capsman_detected: @@ -1899,6 +1903,13 @@ class MikrotikControllerData: if vals["manufacturer"] == "detect": self.data["host"][uid]["manufacturer"] = "" + # Count hosts + if self.data["host"][uid]["available"]: + if vals["source"] in ["capsman", "wireless"]: + self.data["resource"]["clients_wireless"] += 1 + else: + self.data["resource"]["clients_wired"] += 1 + # --------------------------- # process_accounting # --------------------------- diff --git a/custom_components/mikrotik_router/sensor_types.py b/custom_components/mikrotik_router/sensor_types.py index 83c86cb..81b854f 100644 --- a/custom_components/mikrotik_router/sensor_types.py +++ b/custom_components/mikrotik_router/sensor_types.py @@ -247,6 +247,36 @@ SENSOR_TYPES = { data_uid="", data_reference="", ), + "system_clients-wired": MikrotikSensorEntityDescription( + key="system_clients-wired", + name="Wired Clients", + icon="mdi:lan", + native_unit_of_measurement=None, + device_class=None, + state_class=None, + entity_category=None, + ha_group="System", + data_path="resource", + data_attribute="clients_wired", + data_name="", + data_uid="", + data_reference="", + ), + "system_clients-wireless": MikrotikSensorEntityDescription( + key="system_clients-wireless", + name="Wireless Clients", + icon="mdi:wifi", + native_unit_of_measurement=None, + device_class=None, + state_class=None, + entity_category=None, + ha_group="System", + data_path="resource", + data_attribute="clients_wireless", + data_name="", + data_uid="", + data_reference="", + ), "traffic_tx": MikrotikSensorEntityDescription( key="traffic_tx", name="TX",