[Custom component] AsusRouter integration

0.15.1 :open_book: Dutch translation

2022-12-18

:open_book: Translations

  • Added :netherlands: Dutch translation (author: @poudenes)


Changes in 0.15.0

Can be found here


:books: Add your language

AsusRouter already supports 8 languages. You can help with adding language you are fluent (or just good) in.

Curious, who are the authors of the translations? Check it out in the official AsusRouter docs.

Greetings,

I just updated to v.0.15.0 and noticed that the original temperature sensor entities are now unavailable, but new sensors (currently disabled by default) are available. Screenshot attached below shows the unavailable entities in yellow, and the new entities in blue.

Am I to delete the old entities and activate the new ones to use in their place?

Thanks!

ASUS Router - Temp Entities

Hey,

Yes, seems that such a problem might happen on the update. Unfortunately, you would need to remove the old entities and enable new ones. In case you are using them in automations / frontend, you can assign the same entity_idā€™s as before as soon as the unavailable entities are removed.

I will add this problem to the release notes.

Understood - and it isnā€™t a big deal! Just wanted to make sure I didnā€™t miss a step somewhere.

Thanks again for an awesome integration!

:gun: More Asus integrations in this town

Seems like now there will be 3 integrations for Asus routers:

  • AsusRouter custom integration (<-- you are here).
  • AsusWRT built into HA Core (the stock integration).
  • AsusWRT custom by one of the stock integration maintainers, which just got added to HA brands. Apparently, this means, it is heading to be added to the HACS default integrations list. Before it was ā€œjust for testing purposesā€. The difference with the stock - is the added HTTP API support (the one which is used by AsusRouter) for which PR to the HA core is stale for many months.

:+1: Apparently, AsusRouter is doing something right

since the library behind the ā€œnewā€ custom integration just borrowed our temperature sensor parsers and regular expressions - the ones needed to support different values templates between FW versions 374.x, 380.x, 386.x and 388.x


:christmas_tree: AsusRouter is staying with you and becoming even better

Regardless of the success of the stock and the new custom integrations, AsusRouter is going to stay with you as a feature-full and customizable integration.

Do you like AsusRouter? Let the word about it get to other users of Asus devices. Maybe, they donā€™t yet know about the better alternative to AsusWRT core integration.

:gift:

10 Likes

0.16.0 :gift: Many small improvements

2022-12-25

This release is not bringing many new features and some of the changes will not be visible to the end users. But it is here to improve both - your experience of using AsusRouter (keeping all the settings as consistent inside the integration as possible) and my work on the new features and bug fixes.

:rocket: Features

  • Improved hiding of protected values from the entities attributes
  • Security-protected attributes are hidden from the binary_sensor entities
  • Move all the control/no-control features from the library to the integration
  • The confirmation step is removed from the options flow as obsolete - there is no need anymore to manually reload the integration after changing its settings

:bug: Bug fixes

  • Fixed Device is connected in no-control mode. Sending commands is blocked when in no-control mode, raised by the update entity.
  • Fixed bug with missing timemaps in parental control rules (report #369)

:boom: Breaking

  • Services asusrouter.adjust_wlan and asusrouter.device_internet_access are available only in control mode of the integration - which would be the correct expected behaviour.

:package: Dependencies

:hammer: Other changes

  • Simplified obtaining of temperature sensors list from the backend
  • Simplified code for static entities
  • Simplified generation of the static entities
  • Improved constants usage

:medal_sports: Stats

  • 629+ installations
  • 421+ users have checked the Documentation in the last 30 days

: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

:christmas_tree: Happy Holidays!

6 Likes

and nowā€¦ turn off the pc, enjoy Holiday!!!

3 Likes

Thank you so much for this. My phone gps isnā€™t reliable so use this as a primary tracker.

Recently (maybe since the latest merlin update?) my phone isnā€™t updating as Away (always Home). I noticed in the attributes the last Activity is updating even though I have been away from home WiFi for an hour. I confirmed the MAC is correct.

Definitely enjoy the holiday vs thinking about this though!

Iā€™ll try to gather some more info this evening.

I wouldnā€™t rely on the gps integration in ha, as it seems to ā€œfallbackā€ to the ā€œphone operatorsā€ basic infoā€¦ showing me ā€œpermanentlyā€ more than 200km south of my ā€œHomeā€ , i have no problems with the GPS on the phone, if f.ex. driving my car after a google or other ā€œrouteā€ maps ā€¦ AsusRouter are the first instance to discover my phone , halfway up my driveway ( on a good day ) :slight_smile:
EDIT: to ha-gps defense i should maybe mention that i live on the countryside, surrounded by high trees, and a ā€œspotā€ (consumer/revenue) neglected by most phone-companies here.

1 Like

Yeah, this is a lifesaver for automation sanity. My GPS is just bad no matter what (defective is the best way to describe it) as even in Maps it shows me off the road.

I really wish HA zones could be configured to accept ssids as criteria also. Off topic I know :slight_smile:

Just checked again on the attributes and my phone ā€˜last activityā€™ is still updating though I am 100 miles away.

1 Like

Actually it almost ā€œkilledā€ me, after initially using trackers created by default-ha integrations ( latest ASUSWRT ) and switching to AsusRouter ( well actually after when i got my Asus-Router-Hardware, last December ) , my heart jumped when suddenly my courtyard was lighted up before i entered :joy:

1 Like

No surprise but looks like this was a problem with my router. I tried to access the web interface and it wouldnā€™t connect. Rebooted it and back to working now. Keep up the great work!

This happens to my router from time to timeā€¦ This is my second ASUS router and the previous one was even worse. It happens more frequently when I change settings, like adding new entries to the DHCP reservation table.

In the end Iā€™ve set an automation to power cycle (cut power for 30s and then power on again, using a smart switch) the router when I donā€™t receive data on the integration for a certain time.

This is my automation:

alias: Media centre - Router - Recover when unavailable
description: ""
trigger:
  - id: Restart HTTP service
    platform: state
    entity_id:
      - sensor.router_cpu
      - sensor.router_boot_time
      - sensor.router_ram
      - update.router_firmware_update
    to:
      - unavailable
      - unknown
    for:
      hours: 0
      minutes: 5
      seconds: 0
  - id: Reboot router
    platform: state
    entity_id:
      - sensor.router_cpu
      - sensor.router_boot_time
      - sensor.router_ram
      - update.router_firmware_update
    to:
      - unavailable
      - unknown
    for:
      hours: 0
      minutes: 15
      seconds: 0
  - id: Power cycle router
    platform: state
    entity_id:
      - sensor.router_cpu
      - sensor.router_boot_time
      - sensor.router_ram
      - update.router_firmware_update
    to:
      - unavailable
      - unknown
    for:
      hours: 0
      minutes: 30
      seconds: 0
condition: []
action:
  - service: notify.signal_edward
    data:
      message: >-
        Router unavailable ({{ state_attr(trigger.entity_id, 'friendly_name') }}
        is {{ states(trigger.entity_id) }}).

        {{ trigger.id }}.
    continue_on_error: true
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - choose:
      - conditions:
          - condition: trigger
            id: Restart HTTP service
        sequence:
          - service: button.press
            data: {}
            target:
              entity_id: button.router_restart_http_daemon
      - conditions:
          - condition: trigger
            id: Reboot router
        sequence:
          - service: button.press
            data: {}
            target:
              entity_id: button.router_reboot
      - conditions:
          - condition: trigger
            id: Power cycle router
        sequence:
          - service: script.media_centre_router_power_cycle
            data: {}
mode: single

And this is the script called by the end (to power cycle the router):

alias: Media centre - Router - Power cycle
icon: mdi:router-wireless-off
mode: single
sequence:
  - service: switch.turn_off
    data: {}
    target:
      entity_id: switch.media_centre_power_strip_socket_1
  - delay:
      hours: 0
      minutes: 0
      seconds: 30
      milliseconds: 0
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.media_centre_power_strip_socket_1
2 Likes

Hi All,

I see those errors sometimes pop up in HA log:

2022-12-27 09:32:02.547 ERROR (MainThread) [custom_components.asusrouter.router] Error fetching wan data: None

2022-12-27 09:32:02.554 ERROR (MainThread) [custom_components.asusrouter.router] Error fetching wlan data: None

2022-12-27 09:32:03.545 ERROR (MainThread) [custom_components.asusrouter.router] Error fetching gwlan data: None

2022-12-27 09:32:03.558 ERROR (MainThread) [custom_components.asusrouter.router] Error fetching parental_control data: None

2022-12-27 09:32:05.544 ERROR (MainThread) [custom_components.asusrouter.router] Error fetching vpn data: None

Asus Router: GT AX 11000

Asus Integration: 0.16.0
Home Assistant 2022.12.8
Supervisor 2022.11.2
Operating System 9.4
Frontend 20221213.1 - latest

Hey, @poudenes,

Could you please check the full log, whether it shows any more info except for those error messages? They just mean the sensors were not able to update on the scheduled time. Since all 5 are at almost the same time, I suppose the integration got disconnected from the router.

  • Did sensors recover after the errors or did they stuck in some state?
  • Were there any more of the same errors afterwards?
  • Can you connect to your device via Web UI?

If all the sensors recovered, there might have been some random bug in the device API, so it did not reply for some time.
If not and your device can be accessed via Web UI, you would probably need to reload the integration and check whether it will be able to connect correctly.
If the Web UI cannot be reached, you will probably need to reboot your router.

Let me know, what you will find.


:hammer: About some cases of device_tracker entities being stuck home

I know about this issue and trying to solve it. Unfortunately, it is not easy to track:

  • it happens with some devices only
  • there is no correlation with the FW type or version
  • even though it happens more with Merlin, some devices with the stock FW also experience it

Soon enough, devices with newer FW (386+) will get the possibility to use another API endpoint for device tracking. Hopefully, this will help with the issue.

They are still updated. Itā€™s sometimes it canā€™t get the info. There are no errors more than this.

the sensors are updating.

Iā€™ve started seeing errors at startup, Iā€™ve tried removing my custom switch definitions but the errors still occur. Any thoughts on what Iā€™m missing greatly appreciated.

Log Details (ERROR)

This error originated from a custom integration.

Logger: custom_components.asusrouter.router
Source: helpers/update_coordinator.py:201
Integration: AsusRouter ([documentation](https://asusrouter.vaskivskyi.com/), [issues](https://github.com/Vaskivskyi/ha-asusrouter/issues))
First occurred: 18:56:08 (1 occurrences)
Last logged: 18:56:08

Error fetching gwlan data: ("Wrong value deny of type <class 'str'>", None)

and

Log Details (ERROR)

Logger: homeassistant.components.switch
Source: custom_components/asusrouter/entity.py:125
Integration: Switch ([documentation](https://www.home-assistant.io/integrations/switch), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+switch%22))
First occurred: 18:56:08 (2 occurrences)
Last logged: 18:56:09

* Error adding entities for domain switch with platform asusrouter
* Error while setting up asusrouter platform for switch

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 428, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 615, in _async_add_entity original_icon=entity.icon, File "/config/custom_components/asusrouter/entity.py", line 132, in icon if self.is_on: File "/config/custom_components/asusrouter/entity.py", line 125, in is_on return self.coordinator.data.get(self.entity_description.key) AttributeError: 'NoneType' object has no attribute 'get'

Can you please check, whether there is any more trace data in the full HA log? For the first error:

Error fetching gwlan data: ("Wrong value deny of type <class 'str'>", None)

I suppose, before getting such errors, you have changed some of the guest network settings?

Thank you, Iā€™ll check when it next happens. There are a couple of guest networks, what settings might affect this?

Here is data from the full log, hopefully itā€™s helpful.

2022-12-29 00:42:43.508 ERROR (MainThread) [custom_components.asusrouter.router] Error fetching gwlan data: ("Wrong value deny of type <class 'str'>", None)
2022-12-29 00:42:43.622 INFO (MainThread) [homeassistant.components.device_tracker] Setting up device_tracker.asusrouter
2022-12-29 00:42:43.658 ERROR (MainThread) [homeassistant.components.switch] Error adding entities for domain switch with platform asusrouter
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 428, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 615, in _async_add_entity
original_icon=entity.icon,
File "/config/custom_components/asusrouter/entity.py", line 132, in icon
if self.is_on:
File "/config/custom_components/asusrouter/entity.py", line 125, in is_on
return self.coordinator.data.get(self.entity_description.key)
AttributeError: 'NoneType' object has no attribute 'get'
2022-12-29 00:42:43.662 ERROR (MainThread) [homeassistant.components.switch] Error while setting up asusrouter platform for switch
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 289, in _async_setup_platform
await asyncio.gather(*pending)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 428, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 615, in _async_add_entity
original_icon=entity.icon,
File "/config/custom_components/asusrouter/entity.py", line 132, in icon
if self.is_on:
File "/config/custom_components/asusrouter/entity.py", line 125, in is_on
return self.coordinator.data.get(self.entity_description.key)
AttributeError: 'NoneType' object has no attribute 'get'

and

2022-12-29 02:52:43.848 ERROR (MainThread) [custom_components.asusrouter.router] Error fetching wan data: None
2022-12-29 02:52:44.849 ERROR (MainThread) [custom_components.asusrouter.router] Error fetching vpn data: None
2022-12-29 02:53:13.848 ERROR (MainThread) [custom_components.asusrouter.router] Error fetching wlan data: None
2022-12-29 02:53:13.850 ERROR (MainThread) [custom_components.asusrouter.router] Error fetching parental_control data: None
2022-12-29 02:53:13.853 ERROR (MainThread) [homeassistant.helpers.template_entity] TemplateError('TypeError: 'NoneType' object is not iterable') while processing template 'Template("{{ state_attr("switch.rt_ac86u_parental_control", "list") | list | count > 0 }}")' for attribute '_attr_available' in entity 'switch.internet_DEVICENAME'
2022-12-29 02:53:13.862 ERROR (MainThread) [homeassistant.helpers.template_entity] TemplateError('TypeError: 'NoneType' object is not iterable') while processing template 'Template("{% set ns = namespace(
name = "DEVICENAME",
list = state_attr("switch.rt_ac86u_parental_control", "list"),
internet = true
) %} {# Find whether #} {% for element in ns.list %}
{% if element.name == ns.name and element.state == "block" %}
{% set ns.internet = false %}
{% endif %}
{% endfor %} {{ ns.internet }}")' for attribute '_state' in entity 'switch.internet_DEVICENAME'
2022-12-29 02:53:13.864 ERROR (MainThread) [homeassistant.helpers.template_entity] TemplateError('TypeError: 'NoneType' object is not iterable') while processing template 'Template("{{ state_attr("switch.rt_ac86u_parental_control", "list") | list | count > 0 }}")' for attribute '_attr_available' in entity 'switch.internet_DEVICENAME2'
2022-12-29 02:53:13.865 ERROR (MainThread) [homeassistant.helpers.template_entity] TemplateError('TypeError: 'NoneType' object is not iterable') while processing template 'Template("{% set ns = namespace(
name = "DEVICENAME2",
list = state_attr("switch.rt_ac86u_parental_control", "list"),
internet = true
) %} {# Find whether #} {% for element in ns.list %}
{% if element.name == ns.name and element.state == "block" %}
{% set ns.internet = false %}
{% endif %}
{% endfor %} {{ ns.internet }}")' for attribute '_state' in entity 'switch.internet_DEVICENAME2'