mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-22 03:34:23 +02:00
Removed WAN prefix in RouterOS 7+ client bandwidth, fixes #155
This commit is contained in:
parent
4d5030297f
commit
25a09498d6
3 changed files with 44 additions and 4 deletions
|
@ -2124,8 +2124,8 @@ class MikrotikControllerData:
|
|||
"host-name": vals["host-name"],
|
||||
"previous-bytes-up": 0.0,
|
||||
"previous-bytes-down": 0.0,
|
||||
"wan-tx": 0.0,
|
||||
"wan-rx": 0.0,
|
||||
"tx": 0.0,
|
||||
"rx": 0.0,
|
||||
"tx-rx-attr": uom_type,
|
||||
"available": False,
|
||||
"local_accounting": False,
|
||||
|
@ -2175,7 +2175,7 @@ class MikrotikControllerData:
|
|||
previous_tx = self.data["client_traffic"][uid]["previous-bytes-up"]
|
||||
if time_diff:
|
||||
delta_tx = max(0, current_tx - previous_tx) * 8
|
||||
self.data["client_traffic"][uid]["wan-tx"] = round(
|
||||
self.data["client_traffic"][uid]["tx"] = round(
|
||||
delta_tx / time_diff * uom_div, 2
|
||||
)
|
||||
self.data["client_traffic"][uid]["previous-bytes-up"] = current_tx
|
||||
|
@ -2184,7 +2184,7 @@ class MikrotikControllerData:
|
|||
previous_rx = self.data["client_traffic"][uid]["previous-bytes-down"]
|
||||
if time_diff:
|
||||
delta_rx = max(0, current_rx - previous_rx) * 8
|
||||
self.data["client_traffic"][uid]["wan-rx"] = round(
|
||||
self.data["client_traffic"][uid]["rx"] = round(
|
||||
delta_rx / time_diff * uom_div, 2
|
||||
)
|
||||
self.data["client_traffic"][uid]["previous-bytes-down"] = current_rx
|
||||
|
|
|
@ -68,6 +68,8 @@ def update_items(inst, config_entry, mikrotik_controller, async_add_entities, se
|
|||
"environment",
|
||||
"traffic_rx",
|
||||
"traffic_tx",
|
||||
"client_traffic_rx",
|
||||
"client_traffic_tx",
|
||||
"client_traffic_lan_rx",
|
||||
"client_traffic_lan_tx",
|
||||
"client_traffic_wan_rx",
|
||||
|
@ -82,6 +84,8 @@ def update_items(inst, config_entry, mikrotik_controller, async_add_entities, se
|
|||
MikrotikClientTrafficSensor,
|
||||
MikrotikClientTrafficSensor,
|
||||
MikrotikClientTrafficSensor,
|
||||
MikrotikClientTrafficSensor,
|
||||
MikrotikClientTrafficSensor,
|
||||
],
|
||||
):
|
||||
if sensor.startswith("traffic_") and not config_entry.options.get(
|
||||
|
|
|
@ -385,6 +385,42 @@ SENSOR_TYPES = {
|
|||
data_reference="mac-address",
|
||||
data_attributes_list=DEVICE_ATTRIBUTES_CLIENT_TRAFFIC,
|
||||
),
|
||||
"client_traffic_tx": MikrotikSensorEntityDescription(
|
||||
key="client_traffic_tx",
|
||||
name="TX",
|
||||
icon="mdi:upload-network",
|
||||
native_unit_of_measurement="data__tx-rx-attr",
|
||||
device_class=None,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
entity_category=None,
|
||||
ha_group="",
|
||||
ha_connection=CONNECTION_NETWORK_MAC,
|
||||
ha_connection_value="data__mac-address",
|
||||
data_path="client_traffic",
|
||||
data_attribute="tx",
|
||||
data_name="host-name",
|
||||
data_uid="",
|
||||
data_reference="mac-address",
|
||||
data_attributes_list=DEVICE_ATTRIBUTES_CLIENT_TRAFFIC,
|
||||
),
|
||||
"client_traffic_rx": MikrotikSensorEntityDescription(
|
||||
key="client_traffic_rx",
|
||||
name="RX",
|
||||
icon="mdi:download-network",
|
||||
native_unit_of_measurement="data__tx-rx-attr",
|
||||
device_class=None,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
entity_category=None,
|
||||
ha_group="",
|
||||
ha_connection=CONNECTION_NETWORK_MAC,
|
||||
ha_connection_value="data__mac-address",
|
||||
data_path="client_traffic",
|
||||
data_attribute="rx",
|
||||
data_name="host-name",
|
||||
data_uid="",
|
||||
data_reference="mac-address",
|
||||
data_attributes_list=DEVICE_ATTRIBUTES_CLIENT_TRAFFIC,
|
||||
),
|
||||
"environment": MikrotikSensorEntityDescription(
|
||||
key="environment",
|
||||
name="",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue