mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-08 08:24:30 +02:00
Fixed traffic sensor names, ref #306
This commit is contained in:
parent
6079affcfa
commit
4b610ba4e5
2 changed files with 31 additions and 31 deletions
|
@ -39,7 +39,7 @@ async def async_setup_entry(
|
||||||
dispatcher = {
|
dispatcher = {
|
||||||
"MikrotikSensor": MikrotikSensor,
|
"MikrotikSensor": MikrotikSensor,
|
||||||
"MikrotikInterfaceTrafficSensor": MikrotikInterfaceTrafficSensor,
|
"MikrotikInterfaceTrafficSensor": MikrotikInterfaceTrafficSensor,
|
||||||
# "MikrotikClientTrafficSensor": MikrotikClientTrafficSensor,
|
"MikrotikClientTrafficSensor": MikrotikClientTrafficSensor,
|
||||||
}
|
}
|
||||||
await async_add_entities(hass, config_entry, dispatcher)
|
await async_add_entities(hass, config_entry, dispatcher)
|
||||||
|
|
||||||
|
@ -109,27 +109,27 @@ class MikrotikInterfaceTrafficSensor(MikrotikSensor):
|
||||||
return attributes
|
return attributes
|
||||||
|
|
||||||
|
|
||||||
# # ---------------------------
|
# ---------------------------
|
||||||
# # MikrotikClientTrafficSensor
|
# MikrotikClientTrafficSensor
|
||||||
# # ---------------------------
|
# ---------------------------
|
||||||
# class MikrotikClientTrafficSensor(MikrotikSensor):
|
class MikrotikClientTrafficSensor(MikrotikSensor):
|
||||||
# """Define an Mikrotik MikrotikClientTrafficSensor sensor."""
|
"""Define an Mikrotik MikrotikClientTrafficSensor sensor."""
|
||||||
#
|
|
||||||
# @property
|
@property
|
||||||
# def name(self) -> str:
|
def custom_name(self) -> str:
|
||||||
# """Return the name."""
|
"""Return the name for this entity"""
|
||||||
# return f"{self.entity_description.name}"
|
return f"{self.entity_description.name}"
|
||||||
#
|
|
||||||
# # @property
|
# @property
|
||||||
# # def available(self) -> bool:
|
# def available(self) -> bool:
|
||||||
# # """Return if controller and accounting feature in Mikrotik is available.
|
# """Return if controller and accounting feature in Mikrotik is available.
|
||||||
# # Additional check for lan-tx/rx sensors
|
# Additional check for lan-tx/rx sensors
|
||||||
# # """
|
# """
|
||||||
# # if self.entity_description.data_attribute in ["lan-tx", "lan-rx"]:
|
# if self.entity_description.data_attribute in ["lan-tx", "lan-rx"]:
|
||||||
# # return (
|
# return (
|
||||||
# # self.coordinator.connected()
|
# self.coordinator.connected()
|
||||||
# # and self._data["available"]
|
# and self._data["available"]
|
||||||
# # and self._data["local_accounting"]
|
# and self._data["local_accounting"]
|
||||||
# # )
|
# )
|
||||||
# # else:
|
# else:
|
||||||
# # return self.coordinator.connected() and self._data["available"]
|
# return self.coordinator.connected() and self._data["available"]
|
||||||
|
|
|
@ -505,7 +505,7 @@ SENSOR_TYPES: tuple[MikrotikSensorEntityDescription, ...] = (
|
||||||
data_uid="",
|
data_uid="",
|
||||||
data_reference="mac-address",
|
data_reference="mac-address",
|
||||||
data_attributes_list=DEVICE_ATTRIBUTES_CLIENT_TRAFFIC,
|
data_attributes_list=DEVICE_ATTRIBUTES_CLIENT_TRAFFIC,
|
||||||
# func="MikrotikClientTrafficSensor",
|
func="MikrotikClientTrafficSensor",
|
||||||
),
|
),
|
||||||
MikrotikSensorEntityDescription(
|
MikrotikSensorEntityDescription(
|
||||||
key="client_traffic_lan_rx",
|
key="client_traffic_lan_rx",
|
||||||
|
@ -526,7 +526,7 @@ SENSOR_TYPES: tuple[MikrotikSensorEntityDescription, ...] = (
|
||||||
data_uid="",
|
data_uid="",
|
||||||
data_reference="mac-address",
|
data_reference="mac-address",
|
||||||
data_attributes_list=DEVICE_ATTRIBUTES_CLIENT_TRAFFIC,
|
data_attributes_list=DEVICE_ATTRIBUTES_CLIENT_TRAFFIC,
|
||||||
# func="MikrotikClientTrafficSensor",
|
func="MikrotikClientTrafficSensor",
|
||||||
),
|
),
|
||||||
MikrotikSensorEntityDescription(
|
MikrotikSensorEntityDescription(
|
||||||
key="client_traffic_wan_tx",
|
key="client_traffic_wan_tx",
|
||||||
|
@ -547,7 +547,7 @@ SENSOR_TYPES: tuple[MikrotikSensorEntityDescription, ...] = (
|
||||||
data_uid="",
|
data_uid="",
|
||||||
data_reference="mac-address",
|
data_reference="mac-address",
|
||||||
data_attributes_list=DEVICE_ATTRIBUTES_CLIENT_TRAFFIC,
|
data_attributes_list=DEVICE_ATTRIBUTES_CLIENT_TRAFFIC,
|
||||||
# func="MikrotikClientTrafficSensor",
|
func="MikrotikClientTrafficSensor",
|
||||||
),
|
),
|
||||||
MikrotikSensorEntityDescription(
|
MikrotikSensorEntityDescription(
|
||||||
key="client_traffic_wan_rx",
|
key="client_traffic_wan_rx",
|
||||||
|
@ -568,7 +568,7 @@ SENSOR_TYPES: tuple[MikrotikSensorEntityDescription, ...] = (
|
||||||
data_uid="",
|
data_uid="",
|
||||||
data_reference="mac-address",
|
data_reference="mac-address",
|
||||||
data_attributes_list=DEVICE_ATTRIBUTES_CLIENT_TRAFFIC,
|
data_attributes_list=DEVICE_ATTRIBUTES_CLIENT_TRAFFIC,
|
||||||
# func="MikrotikClientTrafficSensor",
|
func="MikrotikClientTrafficSensor",
|
||||||
),
|
),
|
||||||
MikrotikSensorEntityDescription(
|
MikrotikSensorEntityDescription(
|
||||||
key="client_traffic_tx",
|
key="client_traffic_tx",
|
||||||
|
@ -589,7 +589,7 @@ SENSOR_TYPES: tuple[MikrotikSensorEntityDescription, ...] = (
|
||||||
data_uid="",
|
data_uid="",
|
||||||
data_reference="mac-address",
|
data_reference="mac-address",
|
||||||
data_attributes_list=DEVICE_ATTRIBUTES_CLIENT_TRAFFIC,
|
data_attributes_list=DEVICE_ATTRIBUTES_CLIENT_TRAFFIC,
|
||||||
# func="MikrotikClientTrafficSensor",
|
func="MikrotikClientTrafficSensor",
|
||||||
),
|
),
|
||||||
MikrotikSensorEntityDescription(
|
MikrotikSensorEntityDescription(
|
||||||
key="client_traffic_rx",
|
key="client_traffic_rx",
|
||||||
|
@ -610,7 +610,7 @@ SENSOR_TYPES: tuple[MikrotikSensorEntityDescription, ...] = (
|
||||||
data_uid="",
|
data_uid="",
|
||||||
data_reference="mac-address",
|
data_reference="mac-address",
|
||||||
data_attributes_list=DEVICE_ATTRIBUTES_CLIENT_TRAFFIC,
|
data_attributes_list=DEVICE_ATTRIBUTES_CLIENT_TRAFFIC,
|
||||||
# func="MikrotikClientTrafficSensor",
|
func="MikrotikClientTrafficSensor",
|
||||||
),
|
),
|
||||||
MikrotikSensorEntityDescription(
|
MikrotikSensorEntityDescription(
|
||||||
key="environment",
|
key="environment",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue