[Custom component] AsusRouter integration

Great work!!

I have linked various Asus Router device tracker to various Person entities and it is working great wrt. identifying is someone is being home.

But having problems when I try to use Person directly to plan my morning commute route as it lacks the GPS location when sourced by the Asus device tracker and have to work around by changing quite configure redirect my automations and scripts from the Person entities to various mobile app device tracker entities.

Is it possible to add GPS location using an user configurable default home GPS location for all stationary tracker for this type of use case in the future?

GPS is not something routers deal with, at least not that I’ve ever heard. The router has no way to know GPS coordinates of devices connected to it. GPS is not part of LAN networking protocols. All it can really provide is if a device connects/disconnects to the network and identify it by the devices MAC address. The app is different because it can send any data (including GPS coordinates) via whatever network connection is established, back to another app/server that reads and uses it.

We’re way off topic here (sorry) but just use your Home location as your start point and plan your commute from there…your home lat/long is already setup in HA (most likely) so just use this as part of your setup…so if this Integration shows you at home then calc commute from home lat/long to your destination…

Now back to Integration only talk :sunglasses:

Help with “Device Internet Access” template switches please?!,… I’m stumped! Cannot get them working. Anything would be appreciated.

  • The ASUSRouter was installed via HACS. Configured via Integrations.

  • The ASUS router devices and entities show up. The default switches (LED, Wifi, Reboot, etc ) are controllable via the default lovelace dashboard. I had to enable several of the entities that I was planning on controlling.

  • I created template switches to control internet access for several entities - and put them on the main dashboard. YAML is below. Followed instructions from the 0.12.0 release: [Custom component] AsusRouter integration - #211 by Vaskivskyi.

The problem: The dashboard switches are always ON, regardless of the actual block status on the router. When I move them to the OFF position,… they revert back to ON within a few seconds.

  • As a test, I blocked one of the devices directly on the router. The state of the switch does not change on the dashboard.

  • I’ve also tested the “asusrouter.device_internet_access” service via the Automations menu. (Similar to the method here: [Custom component] AsusRouter integration - #220 by TekDad). Using this method, Home Assistant is able to block and unblock the internet access of the same entities. So I think the service and connection between Home Assistant are working correctly.

So I think it’s an issue with the template switch configuration? I’m at a total loss.

Thanks in advance for any help.
-JW

switch:
  - platform: template
    switches:
      internet_nintendo_switch:
        unique_id: internet_nintendo_switch
        value_template: >
          {% set ns = namespace(
            mac = "xx:xx:xx:xx:xx:xx"|upper,
            list = state_attr("switch.rt_ac86u_parental_control","list"),
            internet = true
          ) %}
          {# Find whether #}
          {% for element in ns.list %}
            {% if element.mac == ns.mac and element.state == "block" %}
              {% set ns.internet = false %}
            {% endif %}
          {% endfor %}
          {{ ns.internet }}
        turn_on:
          service: asusrouter.device_internet_access
          data:
            entity_id: device_tracker.nintendo_switch
            state: disable
        turn_off:
          service: asusrouter.device_internet_access
          data:
            entity_id: device_tracker.nintendo_switch
            state: block  

      internet_amazon_firetv_basement_wifi:
        unique_id: internet_amazon_firetv_basement_wifi
        value_template: >
          {% set ns = namespace(
            mac = "xx:xx:xx:xx:xx:xx"|upper,
            list = state_attr("switch.rt_ac86u_parental_control","list"),
            internet = true
          ) %}
          {# Find whether #}
          {% for element in ns.list %}
            {% if element.mac == ns.mac and element.state == "block" %}
              {% set ns.internet = false %}
            {% endif %}
          {% endfor %}
          {{ ns.internet }}
        turn_on:
          service: asusrouter.device_internet_access
          data:
            entity_id: device_tracker.amazon_firetv_basement_wifi
            state: disable
        turn_off:
          service: asusrouter.device_internet_access
          data:
            entity_id: device_tracker.amazon_firetv_basement_wifi
            state: block

Hi All,

Most of time it can’t get the new values:

2023-03-04 17:36:22.803 ERROR (MainThread) [custom_components.asusrouter.router] Error fetching ports_legacy data: None
2023-03-04 17:36:22.810 ERROR (MainThread) [custom_components.asusrouter.router] Error fetching sysinfo data: None
2023-03-04 17:36:22.815 ERROR (MainThread) [custom_components.asusrouter.router] Error fetching parental_control data: None
2023-03-04 17:36:22.819 ERROR (MainThread) [custom_components.asusrouter.router] Error fetching temperature data: None
2023-03-04 17:36:22.824 ERROR (MainThread) [custom_components.asusrouter.router] Error fetching led data: None
2023-03-04 17:36:36.802 ERROR (MainThread) [custom_components.asusrouter.router] Error connecting to '192.168.100.1' for device update: None
2023-03-04 17:36:36.811 ERROR (MainThread) [custom_components.asusrouter.router] Error fetching port_forwarding data: None
2023-03-04 17:36:52.801 ERROR (MainThread) [custom_components.asusrouter.router] Error fetching gwlan data: None
2023-03-04 17:36:52.808 ERROR (MainThread) [custom_components.asusrouter.router] Error fetching network data: None
2023-03-04 17:36:52.818 ERROR (MainThread) [custom_components.asusrouter.router] Error fetching vpn data: None

When reload the integration everything is picked up again.
AsusRouter: 0.21.1
GT-AX11000 - GT-AX11000_388.1_0_ubi.w

:rescue_worker_helmet: Hello there, dear User of AsusRouter,

I know, that from time to time you would like to get an answer to your question or a bug fixed as soon as possible (in terms of hours or a couple of days). I can understand that, but not every time can this be fulfilled.

All the bug reports and other messages are read by me. And all the bugs (that can be fixed) will be fixed. For those, which can not be fixed, another solution will be found (hello, Merlin builds ignoring LED status on reboot).

Please, only consider that AsusRouter is my free-time project in addition to a full-time job. So the amount of time I can spend on it can fluctuate from a couple of hours per day to only an hour per week.

In any case, AsusRouter will improve and progress.


0.22.0 :computer: On the way to a better configuration

2023-03-05

:octopus: GitHub change log ←

:rocket: Features

  • Improved SSDP discovery:
    • Ignore devices with no serial number available
    • Discovery is now based on FW instead of the manufacturer (only discover AsusWRT-powered devices)
  • Improved configuration and options flow:
    • Block multiple setups for a single serial number
    • Configurable options are now sorted into a menu
    • Allow to set up integration with no options (integration can now be setup in 3 short steps)
    • Sorted options to be better grouped
    • When credentials are not changed, the check will be now skipped (to minimize the number of connections)
The new options flow

:bug: Bug fixes

  • Fixed bug in SSDP discovery (report #549)
  • Fixed bug with platform does not generate unique IDs (report #528)

:open_book: Translations

  • Updated Spanish translation (@Nyaran)

:books: Documentation

  • Updated supported devices

:hammer: Other changes

  • Removed lan_speed and wan_speed sensors deprecated in 0.20.0. Please, use the new sensors port_status_lan and port_status_wan (more details)
  • Removed domain name from the entities’ unique ids

:coffee: Support AsusRouter

Monetary support:

  • You can make a donation using the Buy Me a Coffee service

  • Thinking of buying a new Asus router to use with AsusRouter integration? Check the compatibility list in our Docs. If you will use any of the Amazon Associate links, I might get a small (1-3%) bonus from Amazon (usage of the associate links does not change the price of the items for you)

Non-monetary support:

  • Star AsusRouter repository

  • Know a person with an Asus device using Home Assistant but not AsusRouter? Let them know, AsusRouter is cool and has lots of useful features


:open_book: Progress to HA Core - 117 votes


:medal_sports: AsusRouter achivements

  • AsusRouter is already used by at least 822 HA instances (via HA Analytics). 28 days ago we had only 723 installations
  • Our documentation is checked by ~500 users per month (who are not blocking Google Analytics)
1 Like

@joelweston, hello.

You need to change in your actions element.state == "block" to element.type == "block" (use type instead of state)

Also, instead of using

entity_id: device_tracker.nintendo_switch

please use

entities:
  - device_tracker.nintendo_switch
So your code should be
switch:
  - platform: template
    switches:
      internet_nintendo_switch:
        unique_id: internet_nintendo_switch
        value_template: >
          {% set ns = namespace(
            mac = "xx:xx:xx:xx:xx:xx"|upper,
            list = state_attr("switch.rt_ac86u_parental_control","list"),
            internet = true
          ) %}
          {# Find whether #}
          {% for element in ns.list %}
            {% if element.mac == ns.mac and element.type == "block" %}
              {% set ns.internet = false %}
            {% endif %}
          {% endfor %}
          {{ ns.internet }}
        turn_on:
          service: asusrouter.device_internet_access
          data:
            entities:
              - device_tracker.nintendo_switch
            state: disable
        turn_off:
          service: asusrouter.device_internet_access
          data:
            entities:
              - device_tracker.nintendo_switch
            state: block  

      internet_amazon_firetv_basement_wifi:
        unique_id: internet_amazon_firetv_basement_wifi
        value_template: >
          {% set ns = namespace(
            mac = "xx:xx:xx:xx:xx:xx"|upper,
            list = state_attr("switch.rt_ac86u_parental_control","list"),
            internet = true
          ) %}
          {# Find whether #}
          {% for element in ns.list %}
            {% if element.mac == ns.mac and element.type == "block" %}
              {% set ns.internet = false %}
            {% endif %}
          {% endfor %}
          {{ ns.internet }}
        turn_on:
          service: asusrouter.device_internet_access
          data:
            entities:
              - device_tracker.amazon_firetv_basement_wifi
            state: disable
        turn_off:
          service: asusrouter.device_internet_access
          data:
            entities:
              - device_tracker.amazon_firetv_basement_wifi
            state: block

Unfortunately, the examples you have used are already a bit outdated. I am hoping to finally be able to add the correct examples of YAML usage into the AsusRouter documentation, but it takes quite some time.

Feel free to ask if you have any other questions or issues


@poudenes, hello.

Do you use HTTP (non-SSL) connection? If so, please try SSL and let me know if you are still experiencing errors regularly

Wow @Vaskivskyi. Thanks for adjusting my code. Works! I would not have seen those two spots. I had noticed the change to allow multiple entries, but didn’t understand how it impacted your original code example. Appreciate it!

1 Like

Im now tried it with SSL. It will go over the <subdomain>.asuscomm.com with given port.
Let’s see if this will work. Now Asus is in between

If I reboot my router some entities become unavailable and is not restored until I do a reboot of HA. Is that a known ‘bug’? I haven’t investigated it properly. Just thought I’d ask here first.

? … Define, and be just a-little more specific

At least wan_download_speed and wan_upload_speed. I will do some testing tonight.

ok, read this also, so you don’t miss this

Ports | AsusRouter

Sorry, just read your post again :slight_smile: , that you get them back after reboot

Created Letscrypt SSL and disabled captcha with ssl login. Now I can connect via local IP with SSL and integration is running in HA now… Lets see if the errors are gone and solved.

I just wanted to come here and say thank you for this integration (yes I’ve voted for it), you were able to get me to have this on my dashboard which was my end goal (this is also using Extender and Mushroom):

edit: added code for this card just in case

2023-03-06 14_24_29-Window

type: custom:expander-card
gap: 0.6em
padding: 1em
clear: true
title: Network Connected Devices
overlay-margin: 2em
child-padding: 0.5em
button-background: transparent
expanded: true
cards:
  - type: custom:mushroom-chips-card
    chips:
      - type: template
        entity: sensor.rt_ax86u_connected_devices
        content: >-
          Wired: {{ state_attr('sensor.rt_ax86u_connected_devices',
          'devices')|selectattr('connection_type', '==', 'Wired') |list|count }}
        icon: mdi:lan-connect
        icon_color: green
      - type: template
        entity: sensor.rt_ax86u_connected_devices
        icon: mdi:wifi-strength-2
        content: >-
          2.4 GHz: {{ state_attr('sensor.rt_ax86u_connected_devices',
          'devices')|selectattr('connection_type', '==', '2.4
          GHz')|selectattr('guest', '==', false) |list|count }}
        icon_color: blue
      - type: template
        entity: sensor.rt_ax86u_connected_devices
        icon: mdi:wifi
        content: >-
          5 GHz: {{ state_attr('sensor.rt_ax86u_connected_devices',
          'devices')|selectattr('connection_type', '==', '5
          GHz')|selectattr('guest', '==', false) |list|count }}
        icon_color: purple
      - type: template
        entity: sensor.rt_ax86u_connected_devices
        icon: mdi:wifi-cancel
        icon_color: red
        content: >-
          Guest: {{ state_attr('sensor.rt_ax86u_connected_devices',
          'devices')|selectattr('guest', '==', true) |list|count }}
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-entity-card
        entity: binary_sensor.rt_ax86u_f698_wan_status
        name: Internet Status
      - type: custom:mushroom-entity-card
        entity: button.rt_ax86u_reboot
        icon_color: red
        name: Reboot Router
        secondary_info: none
        primary_info: name
        hold_action:
          action: toggle
        tap_action:
          action: more-info
        double_tap_action:
          action: toggle
4 Likes

Out of curiosity, how did you discover that you could get the number of devices connected to each wifi band as well as wired?

1 Like

Couldn’t reproduce entities staying unavailable after router reboot. Perhaps the issue only occurs when wan is disconnected or perhaps it’s fixed in one of the later versions. I’ll keep an eye out.

@ganastor,

This is super cool! :+1:t2: Great dashboard!


@Quacked,

If the entities do not recover without reload of the integration (or HA reboot), that would be a bug. Please, keep track of the entities and let me know your findings. Also, in such cases, there should probably be some errors in the log - that might help as well.

Since updating to HA 2023.3.2 the integration is listed as “! Not Loaded” and I am receiving the following errors in the logs. I’ve tried shutting HA down fully and restarting, but that did not solve the issue. Any ideas?

Logger: homeassistant.setup
Source: setup.py:205
First occurred: 5:04:31 PM (1 occurrences)
Last logged: 5:04:31 PM

Setup failed for custom integration asusrouter: Requirements for asusrouter not found: [‘asusrouter==0.19.3’].

Logger: homeassistant.util.package
Source: util/package.py:107
First occurred: 4:57:31 PM (3 occurrences)
Last logged: 4:57:45 PM

Unable to install package asusrouter==0.19.3: ERROR: Cannot install asusrouter==0.19.3 because these package versions have conflicting dependencies. ERROR: ResolutionImpossible: for help visit Dependency Resolution - pip documentation v24.1.dev0 [notice] A new release of pip is available: 23.0 → 23.0.1 [notice] To update, run: pip install --upgrade pip