Do you want more features to be added to AsusRotuer? Some of the features require an additional testing device. You can help me in getting one → via Donate on Buy Me a Coffee service
I have an automation showing a notification when devices not in my whitelist reconnects. The notification includes IP, name, mac, connection_type and guest. Yesterday I suddenly got 3 notifications with ‘None’ as IP, ‘8C:86:1E:xx:xx:xx’ as name, ‘8C:86:1E:xx:xx:xx’ as MAC and guest as False.
This got me startled for many reasons:
I can’t remember anyone using an Apple device on my network ever (Google says 8C:86:1E is Apple).
It was not connected to my guest network. All my visitors use the guest network.
Why did it say None instead of showing IP and MAC address both as name and MAC? It was also not long enough on my network for me to actually see it being connected in router web page. Even though it notified me 3 times within an hour.
So… any ideas?
Automation
alias: "Notify on reconnection to WiFi"
description: ""
trigger:
- platform: event
event_type: asusrouter_device_reconnected
- platform: event
event_type: asusrouter_device_connected
condition:
- condition: template
value_template: >-
{% set allowlist = state_attr("sensor.asusrouter_allowlist", "list") %}
{% set name = allowlist | selectattr('1', 'eq',
trigger.event.data.mac.upper()) | map(attribute='0') | list | first |
default(none) %}
{{ name is none }}
action:
- service: notify.persistent_notification
data_template:
message: >-
{{trigger.event.data.ip}} | {{trigger.event.data.name}} |
{{trigger.event.data.mac}} | {{trigger.event.data.connection_type}} | {%
if trigger.event.data.guest == True %} Guest: Yes {% else %} Guest: No
{% endif %}
title: A device has reconnected to WiFi
mode: queued
max: 100
That’s strange, but here are a couple of things which I can explain from the AsusRouter point of view:
When the user provides no name for a device and the device itself gives no name, the name has the same value as mac - that is the feature of the library to avoid missing names and related issues.
Absence of the IP can be explained by the fact, the device did not really connect to the network - either did not provide the correct password or just did not finish auth process. This would explain why it only notified in AsusRouter but you did not actually see it in the connected devices list in the Web UI - that was hit and run only, not an actual connection.
Actually, if you live in some neighbourhood where your WiFi coverage extends your property, and your network is not hidden - that might happen - some devices like to scan available networks around in order to check whether they can be used before the user actually tries to connect.
I would say, that is the most convincing explanation. If the device would actually connect - it would obtain an IP address and would probably send its name - e.g. Apple sends at least iPhone/iPad and so as a generic name if not other set by the user.
But you might want to watch your network just in case.
Thank you. I assumed the event required an authenticated connection and not just an attempt of one. Is it possible to identify if it is actually able to connect so I can have a separate notification for that? I live in an apartment building and I guess there will be plenty of times where someone tries to login to my WiFi by mistake (I prefer not to hide SSID).
I saw a brief appearance of an unexpected MAC address recently. Discovered that it was for the wifi interface of a mesh node. Weird thing is that that node is connected to the main router by ethernet (wired) so I wouldn’t expect its wifi interface to try to connect to the main router.
@Quacked, actually it just notifies of any device, that the router has added to the list of connected. Why it does things in this way I don’t know. Actually, if you would be lucky, you would also see it in the Web UI - the source for data is the same as AsusRouter is using
You can update your automation to ignore devices without IP - that would avoid such cases as you had
@Vaskivskyi thank you for all your work on the integration!
I’ve had it working for 2 days, and then after rebooting my Home Assistant, I’m now getting errors on this only:
Logger: homeassistant.config_entries
Source: custom_components/asusrouter/bridge.py:459
Integration: AsusRouter (documentation, issues)
First occurred: 7:18:53 PM (3 occurrences)
Last logged: 7:21:22 PM
Error setting up entry 192.168.1.1 for asusrouter
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 382, 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 748, in setup
await self._init_sensor_coordinators()
File "/config/custom_components/asusrouter/router.py", line 980, in _init_sensor_coordinators
available_sensors = await self.bridge.async_get_available_sensors()
File "/config/custom_components/asusrouter/bridge.py", line 241, in async_get_available_sensors
SENSORS: await self._get_sensors_ports(),
File "/config/custom_components/asusrouter/bridge.py", line 505, in _get_sensors_ports
return await self._get_sensors(
File "/config/custom_components/asusrouter/bridge.py", line 459, in _get_sensors
data = await method()
File "/usr/local/lib/python3.10/site-packages/asusrouter/asusrouter.py", line 1223, in async_get_ports
return await self.async_get_data(
File "/usr/local/lib/python3.10/site-packages/asusrouter/asusrouter.py", line 1120, in async_get_data
await self.async_monitor(_monitor)
File "/usr/local/lib/python3.10/site-packages/asusrouter/asusrouter.py", line 443, in async_monitor
result = process(raw, time=monitor.time)
File "/usr/local/lib/python3.10/site-packages/asusrouter/asusrouter.py", line 640, in _process_monitor_ethernet_ports
data = raw["portSpeed"]
KeyError: 'portSpeed'
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)
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.
→ 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.
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! AsusRouter integration is currently installed in 754 HA instances reporting to Analytics.
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
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 fixes
Fixed bug in the backend library causing errors when device API stops reporting some information (report #C471)
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)
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
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.
Congratulation(HBD) from Northern Europe, and huge thanks for your great work
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