[Custom component] AsusRouter integration

Hey, @hk21x,

It seems, that one of the API endpoints (the one reporting LAN/WAN ports status) is not responding. That happens with some devices. You can try rebooting your router and then reloading integration - it should work again

Of course, this is not a fix, but a shortcut. I will fix the code producing the error and it will be released in the next integration update (sometime this weekend)

I am sorry that you are experiencing this issue

Rebooted. You’re a superstar - thank you.

1 Like

The latest features are amazing, the port forwarding service call is exactly what I have been looking for. I have tried it out and adding port forwarding rules works well, I even have a template value that will add the external port of my phone as it changes. One question though, I cant seem to get the remove service call to work. Are there specific values it requires, I tried using the exact same values in the “action: set” and just changed it to remove, I also tried just using the port forward name but the rule still remains. Any guidance would be appreciate.

service: asusrouter.port_forwarding
data:
  action: set
  ip: 192.168.1.XX
  protocol: TCP
  port: 8089
  ip_external: "{{ states(\"sensor.XX_phone_public_ip_address\") }}"
  port_external: "8089"
  name: Auto SIP WS

service: asusrouter.port_forwarding
data:
  action: remove
  ip: 192.168.1.XX
  protocol: TCP
  port: 8089
  ip_external: "{{ states(\"sensor.XX_phone_public_ip_address\") }}"
  port_external: "8089"
  name: Auto SIP WS

Hey, @vijaykbhatia,

In principle, it should work with just the following:

service: asusrouter.port_forwarding
data:
  action: remove
  ip: 192.168.1.XX
  port_external: "8089"
  protocol: TCP

→ this is the minimum required parameters for remove

Actually, if you have only a single rule for an IP address, you can use the remove_ip action:

service: asusrouter.port_forwarding
data:
  action: remove_ip
  ip: 192.168.1.XX

→ this will remove all the rules for the selected IP.

P.S. The name value is not checked, since it is not actually required and is not a unique parameter of the port forwarding settings.

If it still does not work, please check the log for errors/warnings after calling the service. If needed, please open an issue on GitHub with the info about your device and the log

Thanks this worked a treat. I did find however there must be some rate limit as calling multiple changes through an automation would create problems. I just added a few second wait between service calls.

1 Like

:cake: AsusRouter

Today is the first Birthday of the AsusRouter Python library. The first release was published on 12.02.2022. This was a long and quite productive journey and I hope that AsusRouter will continue growing further.

By the way, the AsusRouter library was downloaded more than 17K times in the last month! :medal_sports: AsusRouter integration is currently installed in 754 HA instances reporting to Analytics.

:wine_glass: Cheers!


0.20.0 :cactus: Port Status

2023-02-12

:octopus: GitHub change log ←

:warning: Deprecation warning

  • Sensors lan_speed and wan_speed are deprecated. They will be removed in version 0.22.0. Please, use the new sensors port_status_lan and port_status_wan

:rocket: Features

  • Added new Port status sensors (LAN - port_status_lan, USB - port_status_usb, WAN - port_status_wan), reporting more information on the physical ports connections. The feature is fully supported by FW version 388.x. With older versions, new sensors might reflect fewer data (mimicking deprecated lan_speed and wan_speed sensors with the new format). More details on the new features

:bug: Bug fixes

  • Fixed bug in the backend library causing errors when device API stops reporting some information (report #C471)

:books: Documentation

  • Updated supported devices

:package: Dependencies

  • Bumped asusrouter library to 0.20.1

:hammer: Other changes

  • Improved code typing
  • Sorted integration manifest to fulfil the latest HA requirements

: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: Our progress on the way to HA Core

We have already received 90 votes. Add your one. More votes we get, the more chance that HA developers will notice it and give a review to the PR in the HA Core repository, which is required to add AsusRouter into Core.

2 Likes

Congratulation(HBD) from Northern Europe, and huge thanks for your great work :+1:

EDIT: And cool to see the Lan-Ports, and USB-Port, thou as it’s states of a value in a list in attributes, im lost … i have no idea how to get there, ive’ tried with various attributes-cards … thou seems like one have to use a template-sensor, for showing those states … would be great if you have any good ideas/card tips for that

EDIT: Never mind, problem solved :wink:
13.02.2023_11.50.20_REC

1 Like

Great integration !!

Got a problem using device_internet_access service after version 17.4.

Background:

  • AX86U (fw 388.1) as main router aimesh with AC68P (fw 386.9) as node
  • Configured AX86U as router, device_tracker, device control checked when set up integration
  • Both devices showed in integration and device_tracker.my_laptop.
  • my_laptop has been added to Parental Controls - Time Scheduling with no schedule, device_tracker.my_laptop enabled in integration.
service: asusrouter.device_internet_access
data:
  entities:
    - device_tracker.my_laptop
  state: disable

In version 17.4, that worked.
Any version later than 17.4, I got this on screen:

Fail to call service asusrouter.device_internet_access. Unknown error.

and this in log:

This error originated from a custom integration.

Logger: homeassistant.helpers.script.websocket_api_script
Source: custom_components/asusrouter/bridge.py:808
Integration: AsusRouter (documentation, issues)
First occurred: 11:33:25 AM (1 occurrences)
Last logged: 11:33:25 AM

websocket_api script: Error executing script. Unexpected error for call_service at pos 1: 'NoneType' object has no attribute 'replace'
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/script.py", line 451, in _async_step
    await getattr(self, handler)()
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/script.py", line 684, in _async_call_service_step
    await service_task
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/core.py", line 1787, in async_call
    task.result()
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/core.py", line 1824, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/home/homeassistant/.homeassistant/custom_components/asusrouter/router.py", line 923, in async_service_device_internet_access
    await self.bridge.async_parental_control(raw=service.data)
  File "/home/homeassistant/.homeassistant/custom_components/asusrouter/bridge.py", line 808, in async_parental_control
    return await self.api.async_set_parental_control_rules(
  File "/srv/homeassistant/lib/python3.10/site-packages/asusrouter/asusrouter.py", line 1351, in async_set_parental_control_rules
    return await self.async_apply_parental_control_rules(current_rules)
  File "/srv/homeassistant/lib/python3.10/site-packages/asusrouter/asusrouter.py", line 1297, in async_apply_parental_control_rules
    request = compilers.parental_control(rules)
  File "/srv/homeassistant/lib/python3.10/site-packages/asusrouter/util/compilers.py", line 144, in parental_control
    timemaps += f"{data[rule].timemap.replace('&#60', '<')}>"
AttributeError: 'NoneType' object has no attribute 'replace'

If I downgrade back to 17.4, service works with no error.
Any help would be appreciated.

@boheme61,

Sorry, I haven’t seen that you have updated your post with a question. I am only getting notifications on “new posts”. But I am glad, you found a solution


@JTPublic,

Sorry to hear that you are experiencing this issue. From the log, it seems like there is a problem in the backend library. Please allow me some time to localize and fix it.

I didn’t wanted you to bother bout this, on the 1st Birthday celebration :wink: … id figured you eventually would see it, but yes i found a perfect “solution” , am about to build a new overview/splash page of my network, where obvious The AsusRouter will have the main role

1 Like

@Vaskivskyi Hi, and thank you for great integration!
Is there any way to determine the secondary WAN (USB modem) operation after failover?
I can try with IP, but I thought you might have some dedicated switch I was unable to find.

You can determine by the Link_rate , for both/either USB ports ( or just “State” of same )

@SuperMaximus, do you mean whether the USB modem started providing an internet connection after the primary WAN failed? Or something else? Please, give an example of how / when you would like to use it, so it would be easier for me to help

Yes, absolutely.
I need to send a HA notification when failover triggers and the USB modem from Secondary WAN becomes an active internet provider (turns from Cold Standby to “Connected”)

Ok, I see. I will check what would be the best way for this

Thanks for this awesome integration. Have been using it for a month or so and it is much better than the default integration, both in terms of stability and feature set.
I have given my vote for this to become part of HA core.

Just wondering if anyone is getting this behaviour where this integration picks up devices and entities from other integrations. See screenshots below. I had the same issue with the default ASUS integration as well. Not sure what this would point to.
To be clear, this doesn’t create any errors but just weird to see the UI like this.

When filtering devices by ASUSROUTER integration:

Showing one of those devices in its own integration. Tasmota in this case also shows that it belongs to AssRouter

Any tips to point me in the right direction would be much appreciated!

Hello, @raphc,

This is the default Home Assistant behaviour and does not depend on AsusRouter.

AsusRouter creates device_tracker entities for all the connected devices. When the MAC address of the connected device is known to HA (such a device exists in another integration), the device tracker is automatically attached to a device and it starts showing in both integrations.

Hi @Vaskivskyi ,
Thanks for the quick answer. Makes a lot of sense.
Will disable those device trackers

0.21.0 :key: Network discovery

2023-02-22

:octopus: GitHub change log ←

:rocket: Features

  • Added network discovery
    Untitled-1
  • Added detailed title for network discovery

:bug: Bug fixes

  • Fixed bug with port forwarding settings, when some of the parameters are not provided (report #538)
  • Fixed bug in parental control service (report #C479)

:boom: Breaking

  • This release is removing direct migration from versions before 0.17.0. If you are still on an older version, please firstly update to any between 0.17.0 and 0.20.0 and only after that update to 0.21.0. The migration guidline for different versions is updated in the documentation

:books: Documentation

  • Updated supported devices

:package: Dependencies

  • Bumped asusrouter library to 0.20.2

:hammer: Other changes

  • Removed name step from the configuration flow

: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: Our progress on the way to HA Core

We have already received 99 votes. Add your one. More votes we get, the more chance that HA developers will notice it and give a review to the PR in the HA Core repository, which is required to add AsusRouter into Core.

After this install (0.21.0) the discovery keeps finding the router after HA restart.
Even when you finished the first discovery and everything was all set