Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read the state of Queues #40

Closed
bruxy70 opened this issue Apr 30, 2020 · 13 comments
Closed

Cannot read the state of Queues #40

bruxy70 opened this issue Apr 30, 2020 · 13 comments
Assignees
Labels
bug Something isn't working testing Solution is being tested

Comments

@bruxy70
Copy link

bruxy70 commented Apr 30, 2020

Describe the issue

The switch entities for the individual queues are not updated when the queue is disabled or enabled. It can write the state, but not read (the other switches e.g. on interfaces or NAT work fine). In the integration, the switch is on all the time, when I turn it off, it will disable the queue, but the switch state will shortly change back to on (but the queue will stay disabled).
Or, if I enable/disable the queue, the switch will stay on all the time.

How to reproduce the issue

Configure a simple queue on the router, Enable/disable the queue and observe the related switch in HA.

Expected behavior

The switch should reflect the state of the queue and can be used to enable/disable queue

Screenshots

image

Software versions

  • Home Assistant version: HA v. 0.109.0
  • Mikrotik Router integration version: v1.5.5
  • Mikrotik Hardware: RB4011iGS+
  • RouterOS version: v6.46.6

Traceback/Error logs

mikrotik_router: the '.translations' directory has been moved, the new name is 'translations', starting with Home Assistant 0.111 your translations will no longer load if you do not move/rename this (but this is not related I suppose - they made a change in 0.109.0 (should have created another bug for that)
And You are using a custom integration for mikrotik_router which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant, which is a default.
No other errors.

@bruxy70 bruxy70 added the bug Something isn't working label Apr 30, 2020
@tomaae
Copy link
Owner

tomaae commented Apr 30, 2020

Could you export your queue config for me so I can have a look on some real settings? I dont use queues at all.
Thanks for info about translations, I have not updated to 0.109 yet.

@bruxy70
Copy link
Author

bruxy70 commented Apr 30, 2020

# software id = B4KA-NAM9
#
# model = RB4011iGS+
# serial number = AAB10A424B92
/queue simple
add max-limit=2M/2M name=YOUTUBE packet-marks=Youtube target=bridge-main
add max-limit=4M/4M name=NETFLIX packet-marks=Netflix target=bridge-main
add max-limit=512k/512k name=APPLE packet-marks=Apple target=bridge-main
add max-limit=128k/512k name=Minecraft packet-marks=Minecraft target=bridge-main

It uses marks done in Mangle, but I do not think this is necessary for this (I have these queues automatically turn on during the day - my and my W use quite a bit of videoconferencing now days, and when kids decide to watch videos at the same time....)

@bruxy70
Copy link
Author

bruxy70 commented Apr 30, 2020

Whilst you are at it. How hard would it be to get the download/upload rate for the query to the attributes? :) So I could detect if there is that kind of traffic....

@tomaae
Copy link
Owner

tomaae commented Apr 30, 2020

Not sure, can you send me mangles for those as well? I will see what I can do about traffic.

@bruxy70
Copy link
Author

bruxy70 commented Apr 30, 2020

/ip firewall mangle
add action=add-dst-to-address-list address-list=Youtube address-list-timeout=30m chain=prerouting comment=\
    "YOUTUBE add address list" content=youtube.com
add action=add-dst-to-address-list address-list=Youtube address-list-timeout=30m chain=prerouting comment=\
    "GOOGLE VIDEO add address list" content=googlevideo.com
add action=add-dst-to-address-list address-list=Netflix address-list-timeout=30m chain=prerouting comment=\
    "NETFLIX add address list" content=nflxvideo.net
add action=add-dst-to-address-list address-list=Netflix address-list-timeout=30m chain=prerouting comment=\
    "NETFLIX add address list" content=netflix.com
add action=mark-packet chain=forward comment="Mark YOUTUBE" new-packet-mark=Youtube passthrough=no \
    src-address-list=Youtube
add action=mark-packet chain=forward comment="Mark Apple" new-packet-mark=Apple passthrough=no \
    src-address-list=Apple
add action=mark-packet chain=forward comment="Mark NETFLIX" new-packet-mark=Netflix passthrough=no \
    src-address-list=Netflix

The rates are available in the queue columns.
image

@bruxy70
Copy link
Author

bruxy70 commented Apr 30, 2020

Oh, and if you want to test it, disable fast path in IP settings. Otherwise the packets will go around mangle...

@tomaae
Copy link
Owner

tomaae commented Apr 30, 2020

Thanks, this will help a lot to setup test environment for queues

tomaae added a commit that referenced this issue May 3, 2020
@tomaae tomaae self-assigned this May 3, 2020
@tomaae tomaae added the testing Solution is being tested label May 3, 2020
@tomaae
Copy link
Owner

tomaae commented May 3, 2020

Changes released in v1.5.6

@tomaae
Copy link
Owner

tomaae commented May 3, 2020

It would be possible to also add sensors for rates, it that would be helpful.

@bruxy70
Copy link
Author

bruxy70 commented May 3, 2020

Works beautifully, thank you. I think the sensor is not necessary, I will dig it out from the attributes. Love it. Thanks for the quick response!

@bruxy70
Copy link
Author

bruxy70 commented May 3, 2020

image

sensor:
  - platform: template
    sensors:
      youtube_download:
        friendly_name: "Youtube download"
        unit_of_measurement: 'Kbps'
        value_template: >
          {% if is_state("switch.mikrotik_queue_youtube","on") %}
            {{ state_attr('switch.mikrotik_queue_youtube', 'Download rate') | regex_replace(find='[a-z]', replace='', ignorecase=True) | int }}
          {% else %}
            0
          {% endif %}

@tomaae
Copy link
Owner

tomaae commented May 3, 2020

True, there are always template sensors.

@tomaae tomaae closed this as completed May 13, 2020
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working testing Solution is being tested
Projects
None yet
Development

No branches or pull requests

2 participants