[Custom component] AsusRouter integration

@boheme61,

AsusRouter does not create devices. It creates device_tracker entities for the wired and wireless devices connected to your router (and only them).

If a device tracker’s MAC address corresponds to the MAC address of a device in Home Assistant, Home Assistant binds them together, which would result in a single device being attributed to 2 (or more) different integrations.

Home Assistant documentation on how devices work..

Here is the source code of the device_tracker module in which you can see, that device trackers are created by themself as independent entities in HA and do not define devices.

The icons you see in your dashboard are showing the AsusRouter icon only because Home Assistant in your case assigned them this way. It should actually be fixed just by a restart of the Home Assistant, they should be showing the Tapo logo first again. This has nothing to do with AsusRouter, but rather with the way Home Assistant works.

Example:


Since the device is assigned to 2 integrations, HA allows downloading diagnostics of any of the integrations. The bad thing is, that Tapo does not have a diagnostics module, as you can see in its source code. Otherwise, it would be available as well (also refer to the snapshot under the spoiler below to see how would it work in case of 2 possible diagnostics to download).

As per why AsusRouter diagnostics stopped working - I would need to check this. There were no reports on the matter and apparently, I missed something in the last releases.


Summary:

  • AsusRouter works the way Home Assistant recommends it and per HA guidelines, it does not create devices and only performs device tracking as it should be
  • Any other integration for routers (including the native HA ASUSWRT integration will do exactly the same merge of a device_tracker into a known device
Especially for this post, I installed ASUSWRT, which also supports Diagnostics as can be seen on the snapshot

  • There is no way to prevent this since this is how Home Assistant works. If you don’t agree, Home Assistant has a separate repository to discuss HA Architecture. Everyone can propose their suggestions to improve HA for all the users.

A possible solution is to completely disable the device tracking part of AsusRouter in the integration configs.

When / if I would implement a possibility to disable / enable selected device_trackers in AsusRouter, it might also solve your issue, without a need to stop all the trackers for all devices.

2 Likes

Hey, @poudenes, this is a purely Merlin feature, isn’t it? I never considered it for development yet, since no one asked before. But I am always open to implementing new features for AsusRouter for all the users. So if you need it, we can add it to the list :wink:

My Bad, Deeply Apologize !, you might have wrote something similar , back when i “raised this” earlier, but not in so clear detailed/description

So maybe the best “solution” would be " for HA devs" to move the “Bind Information” below a step ( Where i.e Info’s in regards to automations/scenes/scripts are, As for me if it’s surely looks weird, and annoying, and you are right, sometimes 3 of 6 shows ASUS icon, other times 4, or 2 shows up with ASUS icon … And it doesn’t matter if i restart, it’s very inconsistent , after latest restart i only had 1 with ASUS icon, without restarting it’s suddenly 4 again … so you can see/understand my “confusions/annoyances” , So honestly i can tell whats going on, But something is not right, A device (and in a device-list) should not change Default Icon Ever, It’s installed in Tapo App, it is a Tapo Device

But thanks for your detailed description, maybe i should “pass this on” to the Core or Tapo repository, im really “confused” about this Odd behavior
Below you see the current “order” ASUS vs Tapo / Tapo vs ASUS, currently 3 seems to be ASUS Devices


After another Reboot Just now

Get my confusions here ? :slight_smile:
And after yet another “Restart” (not reboot as above) … im back at 1, i bet next time it’s 3 or 4 again, ot in awhile … i just can’t figure out what’s “controlling” this behavior


YEP, Restarted again , you see there is no point in me trying to order by “Integration” ( A vs T is far from each-other, and i don’t see ALL my Devices under Tapo, in the Devicelist) luckily i can ordering by Device-name … call my “picky” But this just isn’t right

Random Madness :slight_smile:

This is a weird behaviour you have. I agree, it does not look any nice if it changes all the time. But it never happened to me (I don’t have many devices which are merged with device trackers and only one Tapo camera though).

Ok, yes it’s only my Tapo-cams from “Tapo-Camera-Control”, have 6 of them, but maybe i should “raise” this in Core, as it does seem like it has to do with the “Bind” order, and therefore the view in /Settings/Devices# Devices

GitHub might be down, but something is ready for all those who’ll be trying the next beta soon :mantelpiece_clock:

image

Well, device-trackers are useful, and nothing i intend to “disable” , always good to know whether a device is actually “unavailable/unknown” reported by the Router.
But the mess in the Device-List, could/should be handle a different way, i don’t have any deep “technical”
knowledge of HA’s “architecture”, but if i can’t i.e Sort a Device-List by “integration” i would say “Something is wrong”
A


T

I would Prefer My Tapo Camera Device, is to be found, under the Tapo-Camera-Integration, how to accomplice this, i unfortunately don’t have any “technical” suggestion/solution for

0.23.4 :bug: More legacy bugfixes

2023-11-04

:octopus: GitHub release ←

:bug: Bug fixes

  • Fixed bug with 5 GHz clients for older devices

:package: Dependencies

  • Bumped asusrouter library to 1.0.4

0.23.3 :bug: 380 - 384 bugfixes

2023-11-04

:octopus: GitHub release ←

:bug: Bug fixes

  • Fixed issue for 380 - 384 FW versions (report #661)

:package: Dependencies

  • Bumped asusrouter library to 1.0.3

:coffee: Support AsusRouter

Monetary support:

Non-monetary support:

:wink: For those with stock 388 FW

Spoiler alert

Hi There,

With latest HA and latest Asus integration sometimes the integration won’t start.
Have to reload the integration multiple times before it will work again.

  • Asus integration: 0.23.4
  • Core: 2023.11.1
  • Supervisor: 2023.10.1
  • Operating System: 11.1
  • Frontend: 20231030.1

Below log part of the errors:

2023-11-05 17:11:28.309 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Asus Router for asusrouter
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/asusrouter/connection.py", line 199, in _send_request
    resp_status, resp_headers, resp_content = await self._make_post_request(
                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/asusrouter/connection.py", line 276, in _make_post_request
    async with self._session.post(
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 1141, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 560, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 899, in start
    message, payload = await protocol.read()  # type: ignore[union-attr]
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 616, in read
    await self._waiter
aiohttp.client_exceptions.ClientOSError: [Errno 32] Broken pipe

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 402, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/asusrouter/__init__.py", line 26, in async_setup_entry
    await router.setup()
  File "/config/custom_components/asusrouter/router.py", line 289, in setup
    await self.bridge.async_connect()
  File "/config/custom_components/asusrouter/bridge.py", line 150, in async_connect
    await self.api.async_connect()
  File "/usr/local/lib/python3.11/site-packages/asusrouter/asusrouter.py", line 115, in async_connect
    return await self.async_get_identity() is not None
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/asusrouter/asusrouter.py", line 175, in async_get_identity
    self._identity = await collect_identity(
                     ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/asusrouter/modules/identity.py", line 93, in collect_identity
    endpoints = await _check_endpoints(api_query)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/asusrouter/modules/identity.py", line 167, in _check_endpoints
    endpoints[endpoint] = await check_available(endpoint, api_hook)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/asusrouter/modules/endpoint/__init__.py", line 148, in check_available
    status, _, _ = await api_query(endpoint)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/asusrouter/asusrouter.py", line 242, in async_api_query
    return await self._connection.async_query(endpoint, payload)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/asusrouter/connection.py", line 249, in async_query
    return await self._send_request(endpoint, payload, headers)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/asusrouter/connection.py", line 226, in _send_request
    raise AsusRouterConnectionError from ex
asusrouter.error.AsusRouterConnectionError: None

2023-11-05 17:13:47.952 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Asus Router for asusrouter
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/asusrouter/connection.py", line 199, in _send_request
    resp_status, resp_headers, resp_content = await self._make_post_request(
                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/asusrouter/connection.py", line 276, in _make_post_request
    async with self._session.post(
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 1141, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 560, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 899, in start
    message, payload = await protocol.read()  # type: ignore[union-attr]
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 616, in read
    await self._waiter
aiohttp.client_exceptions.ClientOSError: [Errno 32] Broken pipe

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 402, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/asusrouter/__init__.py", line 26, in async_setup_entry
    await router.setup()
  File "/config/custom_components/asusrouter/router.py", line 289, in setup
    await self.bridge.async_connect()
  File "/config/custom_components/asusrouter/bridge.py", line 150, in async_connect
    await self.api.async_connect()
  File "/usr/local/lib/python3.11/site-packages/asusrouter/asusrouter.py", line 115, in async_connect
    return await self.async_get_identity() is not None
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/asusrouter/asusrouter.py", line 175, in async_get_identity
    self._identity = await collect_identity(
                     ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/asusrouter/modules/identity.py", line 93, in collect_identity
    endpoints = await _check_endpoints(api_query)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/asusrouter/modules/identity.py", line 167, in _check_endpoints
    endpoints[endpoint] = await check_available(endpoint, api_hook)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/asusrouter/modules/endpoint/__init__.py", line 148, in check_available
    status, _, _ = await api_query(endpoint)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/asusrouter/asusrouter.py", line 242, in async_api_query
    return await self._connection.async_query(endpoint, payload)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/asusrouter/connection.py", line 249, in async_query
    return await self._send_request(endpoint, payload, headers)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/asusrouter/connection.py", line 226, in _send_request
    raise AsusRouterConnectionError from ex
asusrouter.error.AsusRouterConnectionError: None

0.23.5 :bug: Error handling

2023-11-05

:octopus: GitHub release ←

:bug: Bug fixes

  • Fixed error handling on integration startup

0.23.6 :clock1: Error loop fix

2023-11-05

:octopus: GitHub release ←

:bug: Bug fixes

  • Fixed an infinite loop with authorization error (report #675)

:package: Dependencies

  • Bumped asusrouter library to 1.0.5

:coffee: Support AsusRouter

Monetary support:

Non-monetary support:

2 Likes

hello,
Before the last update i can see the temperature of all my asus mesh routers. Obviously diferent temperatures because are in diferent places in my house.

With last update, this information is the same in the 3 mesh routers. (cpu, ram, temperature, etc…)

0.23.7 :adhesive_bandage: Client session

2023-11-09

:octopus: GitHub release ←

:rocket: Features

  • Switched to receive a new client session for connection

@DAVIZINHO, please check the new version

1 Like

I have the same problem actually and am on the latest version 0.23.7

It is always random, sometimes the ram is the same, or the CPU temp or all the entities are the same. Very weird.

I have the router added as a router and then I added the node via IP

Hello, guys.

Let’s discuss how we can improve sensors and their attributes. Follow the link:

Sensors and attributes organization · Vaskivskyi/ha-asusrouter · Discussion #695 (github.com)


@HarvinDhillon, I am working on this issue. Hopefully, it will be solved soon

:warning: Beta release!

0.24.0b0

2023-11-12

:octopus: GitHub release ←

:boom: Breaking

  • Implemented changes in wan binary sensor. Refer to the Features section for details

:rocket: Features

  • Added support for VPN Fusion (VPN clients, stock FW 388+)
  • Added support for WireGuard (clients + server) (stock and Merlin FW 388+) (report #594)
  • Added support for OpenVPN (clients + servers) (stock FW 388+) (report #470)
  • Added support for secondary WAN and changed WAN sensors (report #603)
    • Binary sensor wan (wan_secondary)
    • Sensors wan_ip and wan_ip_extra (wan_ip_secondary and wan_ip_secondary_extra)
  • Added internet binary sensor to show the general state of the device internet connection (and IP address as an attribute of the sensor)
  • Added dualwan binary sensor
  • Added wan_aggregation binary sensor

:bug: Bug fixes

  • Fixed issue with blocked possibility to reload integration
  • Fixed diagnostics module

:package: Dependencies

  • Bumped asusrouter library to 1.1.0b0

:coffee: Support AsusRouter

Monetary support:

Non-monetary support:

With this release i lost the teperature for the wifi connections.

Load Average is not working also.

And the IP of VPN client is not shown in attributes.

This is shown in attribues for my VPN:

auth_read: 154753
tcp_udp_read_bytes: 196814
tcp_udp_write_bytes: 119965
tun_tap_read_bytes: 75790
tun_tap_write_bytes: 152465
update_time: "2023-11-13T10:40:06"
icon: mdi:check-network-outline
friendly_name: Privado VPN
templates:
  icon_color: if (state === 'on') return '#1E90FF'; return 'grey';
icon_color: "#1E90FF"

On Asus portal i see the IP showing. So thats working correct.

Firmware: 3.0.0.4.388.4_0 (Merlin)

Hi ALl,

Will it even possible to make switches for “VPN Director” ?
So for every new rule (device) that is setup you get a switch.

Then you can turn it on or off without enter the Asus Portal.

0.24.0b1

2023-11-13

:octopus: GitHub release ←

:bug: Bug fixes

  • Fixed missing values for OpenVPN client
  • Fixed missing temperature sensors
  • Fixed unsafe dictionary operation

:package: Dependencies

  • Bumped asusrouter library to 1.1.0b1

@poudenes, sorry for the inconvenience. The issue with temperature sensors and OpenVPN attributes should be fixed now.

Please, let me know more details about load_avg sensors. For me they work well with 388.4_0. Is there anything in the log?

Regarding VPN Director - this is a Merlin feature and I am not sure, whether it can be accessed with API in a way to be available for the integration. I can check

1 Like

Temperature and IP VPN working again. And thanks for investigating my question.