mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-10 09:24:31 +02:00
added more options to measurement for traffic #10
This commit is contained in:
parent
e418c20252
commit
25e90702d2
2 changed files with 17 additions and 9 deletions
|
@ -14,5 +14,5 @@ DEFAULT_TRACK_ARP = True
|
||||||
DEFAULT_ENCODING = "ISO-8859-1"
|
DEFAULT_ENCODING = "ISO-8859-1"
|
||||||
DEFAULT_LOGIN_METHOD = "plain"
|
DEFAULT_LOGIN_METHOD = "plain"
|
||||||
|
|
||||||
DEFAULT_TRAFFIC_TYPE = "mbps"
|
DEFAULT_TRAFFIC_TYPE = "Kbps"
|
||||||
TRAFFIC_TYPES = ["bps", "kbps", "mbps"]
|
TRAFFIC_TYPES = ["bps", "Kbps", "Mbps", "B/s", "KB/s", "MB/s"]
|
||||||
|
|
|
@ -258,21 +258,29 @@ class MikrotikControllerData:
|
||||||
)
|
)
|
||||||
|
|
||||||
traffic_type = self.option_traffic_type
|
traffic_type = self.option_traffic_type
|
||||||
if traffic_type == "bps":
|
if traffic_type == "Kbps":
|
||||||
|
traffic_div = 0.001
|
||||||
|
elif traffic_type == "Mbps":
|
||||||
|
traffic_div = 0.000001
|
||||||
|
elif traffic_type == "B/s":
|
||||||
|
traffic_div = 0.125
|
||||||
|
elif traffic_type == "KB/s":
|
||||||
|
traffic_div = 0.000125
|
||||||
|
elif traffic_type == "MB/s":
|
||||||
|
traffic_div = 0.000000125
|
||||||
|
else:
|
||||||
|
traffic_type = "bps"
|
||||||
traffic_div = 1
|
traffic_div = 1
|
||||||
elif traffic_type == "kbps":
|
|
||||||
traffic_div = 1000
|
|
||||||
elif traffic_type == "mbps":
|
|
||||||
traffic_div = 1000000
|
|
||||||
|
|
||||||
for uid in self.data["interface"]:
|
for uid in self.data["interface"]:
|
||||||
self.data["interface"][uid]["rx-bits-per-second-attr"] = traffic_type
|
self.data["interface"][uid]["rx-bits-per-second-attr"] = traffic_type
|
||||||
self.data["interface"][uid]["tx-bits-per-second-attr"] = traffic_type
|
self.data["interface"][uid]["tx-bits-per-second-attr"] = traffic_type
|
||||||
self.data["interface"][uid]["rx-bits-per-second"] = round(
|
self.data["interface"][uid]["rx-bits-per-second"] = round(
|
||||||
self.data["interface"][uid]["rx-bits-per-second"] / traffic_div
|
self.data["interface"][uid]["rx-bits-per-second"] * traffic_div
|
||||||
)
|
)
|
||||||
self.data["interface"][uid]["tx-bits-per-second"] = round(
|
self.data["interface"][uid]["tx-bits-per-second"] = round(
|
||||||
self.data["interface"][uid]["tx-bits-per-second"] / traffic_div
|
self.data["interface"][uid]["tx-bits-per-second"] * traffic_div
|
||||||
)
|
)
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue