Skip to content

Commit

Permalink
added download and upload rate attributes for queue switches #40
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaae committed May 3, 2020
1 parent c1c4b41 commit a499d5e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions custom_components/mikrotik_router/mikrotik_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ def get_queue(self):
{"name": ".id"},
{"name": "name", "default": "unknown"},
{"name": "target", "default": "unknown"},
{"name": "rate", "default": "0/0"},
{"name": "max-limit", "default": "0/0"},
{"name": "limit-at", "default": "0/0"},
{"name": "burst-limit", "default": "0/0"},
Expand Down Expand Up @@ -769,6 +770,16 @@ def get_queue(self):
"download-max-limit"
] = f"{round(download_max_limit_bps * uom_div)} {uom_type}"

upload_rate_bps, download_rate_bps = [
int(x) for x in vals["rate"].split("/")
]
self.data["queue"][uid][
"upload-rate"
] = f"{round(upload_rate_bps * uom_div)} {uom_type}"
self.data["queue"][uid][
"download-rate"
] = f"{round(download_rate_bps * uom_div)} {uom_type}"

upload_limit_at_bps, download_limit_at_bps = [
int(x) for x in vals["limit-at"].split("/")
]
Expand Down
2 changes: 2 additions & 0 deletions custom_components/mikrotik_router/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@

DEVICE_ATTRIBUTES_QUEUE = [
"target",
"download-rate",
"upload-rate",
"download-max-limit",
"upload-max-limit",
"upload-limit-at",
Expand Down
Binary file modified docs/assets/images/ui/queue_switch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a499d5e

Please sign in to comment.