[Custom component] AsusRouter integration

Thanks a lot for your support! :heart:

I am always happy when my integration works for others. And that would be rude of me to promise and release a new feature, and keep it breaking something else :smiley:

P.S. Nice dashboards! :+1:

2 Likes

Hey,

Since my memory is not that good anymore :laughing: and in order for you to see the status of new features :mag_right: coming to the integration in future, AsusRouter GitHub (link in the 1 post) now has a section New features development :hammer_and_wrench:. There you can find out what features are considered, in progress or cannot currently be implemented.

If anything is missing from the list, let me know.

1 Like

Release 0.9.2 :rocket: Stability improvement · Vaskivskyi/ha-asusrouter (github.com)

:wrench: The problem with sensors being stuck and not updating after receiving some error from the device should be fixed now :hammer:

Also, some other bug fixes and logging improvements should make everyone’s usage of the integration a bit easier :slightly_smiling_face:

P.S. And a bit more via Release 0.9.3 :hammer_and_wrench: Even more stability · Vaskivskyi/ha-asusrouter (github.com)
P.P.S. Sorry for two releases in a row, but this should really help those users who experienced problems with AsusRouter. :cake:

1 Like

I would like to be notified when a new (unknown) device connects to my WiFi.

In a separate notification I would also like to be notified if a device not in the “whitelist” connects. Like a device that’s not normally at my home connects.

Any suggestions on a good way to achieve this?

Would be great if at all possible. I am interested as well.

You can create a json file with a list of all of your whitelisted devices, convert the content to a sensor and then creomation to check for each device (from device list sensor) if existing I’m the json sensor.

You will find here an example of using a json file into a sensor:

1 Like

Is it possible to turn off and on the internet access for a device, like you can do in the web interface for the router?

image

The integration will get an event triggering soon. The event will have the MAC, IP and name of a newly connected device, so you can use any of them in your automation to be either just notified in HA (like on the snapshot), or to perform whichever action is possible via HA - e.g. compare the device MAC with the ones from your allowlist/blocklist. The event will be triggered only for devices, which were not tracked in the HA yet.

3 Likes

Hello,

Not yet, but this feature is already planned and will be released soon :hammer_and_wrench:

1 Like

:hammer: With the next AsusRouter version, a new asusrouter_device_connected event will be raised in HA. You can use it for any automations. I am attaching an example, of how it can be done just to notify you of a new device connected.

alias: AsusRouter - New device connected
description: Create a HA notification for any new device connected to the local network
trigger:
  - platform: event
    event_type: asusrouter_device_connected
condition: []
action:
  - service: persistent_notification.create
    data_template:
      title: Device has joined the local network
      message: >-
        MAC: {{trigger.event.data.mac}}, IP: {{trigger.event.data.ip}}, name:
        {{trigger.event.data.name}}
mode: queued
max: 100

The event will be raised ONLY for devices, which were not tracked by HA yet. It does not depend on whether you have device_tracker entities enabled or not, since devices are tracked anyway for the connected_devices sensor.

The next AsusRouter version will be released in the following 2 days :watch:

6 Likes

You should work for Asus. I can’t buy a different brand router now with all these awesome features!

2 Likes

You can always buy a coffee for @Vaskivskyi. :wink:

2 Likes

Release 0.10.0 :fire:A new device connected event and new security option :lock: · Vaskivskyi/ha-asusrouter (github.com)

So, here we go:

  • An asusrouter_device_connected event for custom automation (example automation is a couple of messages up in the thread) :fire:
  • A possibility to hide passwords from any sensors and attributes (currently this is for WiFi switches and binary sensors) :lock:
  • A bug fix for when integration disconnects from the device - now it should reconnect properly by itself :hammer:

P.S. @Quacked, nobody said, I know how to program properly - otherwise, there would be fewer bugs :laughing:

5 Likes

:boom: We are finally above 500 active installations* of AsusRouter integration! :bomb:

Installations

*as per HA analytics (so only for installations, sharing data via Analytics integration)
**for comparison, in-built AsusWRT is used in 2217 installations currently

8 Likes

Superb!! I tried the official one looking for the CPU load of my RT-AC86U but it was missing. Yours has this - perfect!
Thank you!

1 Like

I tried subscribing to asusrouter_device_connected under /developer-tools/event but it didn’t trigger when I disconnected and reconnected a device on the network. My sensor.rt_ac68u_connected_devices noticed the reconnection though. Does that mean that the asusrouter_device_connected event is only triggered on NEW devices connected? If so, the event name is a bit confusing.

And what would be the best way of getting a notification when something not in a whitelist connects? Create a text template with a list of MAC addresses as whitelist and compare that to my sensor.rt_ac68u_connected_devices using some fancy templating?

1 Like

I tried this also - yes looks like new devices only. I had an old phone that had not been turned on for a while. It picked that up and sent me the notification. But I switched on some devices (linux machines etc) that had a static IP in my dhcp server, I’m assuming it is ignoring these as they are already configured in the router.
I’ll wait and see what happens when my son comes home with his phone - added a telegram message also in the automation

But a good way of catching people hacking into your lan/wifi.

You could create an automation based on the number of devices if you know how many you have in total on your network. At the moment I have 74 :joy:
But I’m more interested in new devices (unknown ones) joining which I think is what this was designed for

Hey,

Yes, the event is called asusrouter_device_connected even though it fires only for the new devices (which were not tracked by HA yet) - I have tried to emphasize this in my previous comments as well as in the release notes. I was thinking about using new in the name - but I hate too-long names when not needed. Sorry :slightly_smiling_face:

You can easily create template sensors (or whichever entities) for blocklist and allowlist, containing already values (e.g. MAC addresses) as a list as the following (or it can be an attribute of some template entity):

Template YAML for configuration.yaml
template:
  - sensor:
      - name: AsusRouter/Allowlist
        unique_id: asusrouter_allowlist
        state: >
            {{ ["00:aa:00:aa:00:aa", "00:ab:00:ab:00:ab", "00:ac:00:ac:00:ac"] }}
  - sensor:
      - name: AsusRouter/Blocklist
        unique_id: asusrouter_blocklist
        state: >
            {{ ["00:da:00:da:00:da", "00:db:00:db:00:db", "00:dc:00:dc:00:dc"] }}

Then you can use them in your automations

Automation YAML
alias: AsusRouter - New device connected
description: Create a HA notification for any new device connected to the local network
trigger:
  - platform: event
    event_type: asusrouter_device_connected
action:
- choose:
  # In blocklist
  - conditions:
    - condition: template
      value_template: >
        {% set blocklist = states("sensor.asusrouter_blocklist") %}
        {{ trigger.event.data.mac in blocklist }}
    sequence:
    - service: persistent_notification.create
      data_template:
        title: This device should be blocked!
        message: >-
          MAC: {{trigger.event.data.mac}}, IP: {{trigger.event.data.ip}}, name:
          {{trigger.event.data.name}}
  # In allowlist
  - conditions:
    - condition: template
      value_template: >
        {% set allowlist = states("sensor.asusrouter_allowlist") %}
        {{ trigger.event.data.mac in allowlist }}
    sequence:
    - service: persistent_notification.create
      data_template:
        title: Device from allowlist connected
        message: >-
          MAC: {{trigger.event.data.mac}}, IP: {{trigger.event.data.ip}}, name:
          {{trigger.event.data.name}}
  # Unknown
  default:
  - service: persistent_notification.create
    data_template:
      title: Never seen this device yet
      message: >-
        MAC: {{trigger.event.data.mac}}, IP: {{trigger.event.data.ip}}, name:
        {{trigger.event.data.name}}
mode: queued
max: 100

Result:

P.S. Would you really need an event for all the devices connecting, not only new ones? Some devices (e.g. smart watches, modern Windows 10/11 devices with connected sleep mode and many more) like to connect/disconnect from time to time - that would spam too much in HA

I would use it like this: First I would whitelist all devices on my network that belongs to me and my family (about 30). If a friend or visiting family (with my WiFi pass) comes over I would like to get a notification when they connect to know if they affect my network negatively if I’m watching live streams etc. But I guess I could match a whitelist template sensor to the connected devices sensor. Is that any different from using an event for all devices connecting? :thinking:

1 Like