[Custom component] AsusRouter integration

UAU! Thanks a lot! That looks outstanding!
I wish i would be as siklled programmer as you, guys… but, a man can’t have it all, correct? I’m more in electronics hardware then in software.

EDIT: i play with this addon a bit and i managed to sort entites alphabetically - just add

sort_by: [devices+]

to main code.
To alter font size css code is used:

css:
  table: 'width: 100%;font-size: 12px; line-height: 15px;'
  th: 'font-size: 20px;'
  tr td: 'border: 1px solid red;'

Above code sets font of devices to 12px, line height to 15px and font in line “NAMES” to 20px. ANd adds a border around all devices list.
nice card, indeed!

1 Like

I was able to incorporate the list for the ‘Connected Devices’ entity into a ‘Fold Entity Row Card’ using the ‘Flex Table Card’. I was only able to get this to work because of the specific config settings that can be used with the ‘Flex Table Card’, so thanks to the creator of that card as well as the HA-ASUS Router integration! :partying_face: Screenshot and code below…

Home Assistant - Router Stats via Fold Entity Row and Flex Table

type: entities
entities:
  - type: custom:fold-entity-row
    padding: 0
    head:
      entity: sensor.asus_router_connected_devices
      icon: mdi:router-wireless
      tap_action:
        action: none
    entities:
      - type: custom:flex-table-card
        sort_by:
          - devices+
        entities:
          include: sensor.asus_router_connected_devices
        columns:
          - data: devices
            name: ' Device Name'
            icon: mdi:devices
            modify: x.split('/')[2]
          - data: devices
            name: ' Address'
            icon: mdi:ip-network
            modify: x.split('/')[1]
          - data: devices
            name: ' MAC'
            icon: mdi:barcode-scan
            modify: x.split('/')[0]
        card_mod:
          style: |
            ha-card {
              box-shadow: none;
              background: none;
            }

6 Likes

A small announcement for the new feature coming to the integration :slightly_smiling_face:

Announcement image here

2 Likes

Love it. :slight_smile:
I understand those are in seconds. But please help specify unit on the UI somewhere - no need to keep the users guessing.

1 Like

I’ll add the units :slightly_smiling_face:

image

Will be available with the next release

2 Likes

This just made my day! Thank you!

I’ve been manually going in and disabling these entities one-by-one since it has been causing so many issues with my Kasa Devices’ connectivity (don’t ask :rofl: - long story that has nothing to do with your Integration).

Looking forward to it!

:boom: [BREAKING] With version 0.9.0 (when released), the devices attribute of the Connected devices sensor will change the format from a list of strings to a list of dictionaries. As a result, you will need to correct your templates.

I am attaching new versions you will need instead of the 2 types of code we discussed before.

Template with tabs alignment
{% set ns = namespace(
  devices = state_attr('sensor.rt_ax88u_connected_devices', 'devices'),
  max_length = 0,
  max_tabs = 0)
%}
{# Save the maximum length of device names #}
{% for item in state_attr('sensor.rt_ax88u_connected_devices', 'devices') %}
  {%- if item.name|length > ns.max_length %}
    {%- set ns.max_length = item.name|length %}
  {%- endif %}
{% endfor %}
{# Sort #}
{%- set ns.devices = ns.devices|sort(attribute="name", case_sensitive=true) %}
{%- set ns.max_tabs = (ns.max_length / 8)|int %}
{# Output #}
{% for device in ns.devices %}
  {{- device.name }}
  {%- set tabs = (device.name|length / 8) | int %}
  {%- for tab in ['\t']|batch(ns.max_tabs - tabs + 1, '\t') %}
    {%- for el in tab %}
      {{- el }}
    {%- endfor %}
  {%- endfor %}
  {{- device.ip + '\t' + device.mac }}
{% endfor %}
Flex Table Card
type: entities
entities:
  - type: custom:fold-entity-row
    padding: 0
    head:
      entity: sensor.rt_ax88u_connected_devices
      icon: mdi:router-wireless
      tap_action:
        action: none
    entities:
      - type: custom:flex-table-card
        sort_by:
          - devices+
        entities:
          include: sensor.rt_ax88u_connected_devices
        columns:
          - data: devices
            name: ' Device Name'
            icon: mdi:devices
            modify: x.name
          - data: devices
            name: ' Address'
            icon: mdi:ip-network
            modify: x.ip
          - data: devices
            name: ' MAC'
            icon: mdi:barcode-scan
            modify: x.mac
        card_mod:
          style: |
            ha-card {
              box-shadow: none;
              background: none;
            }

You will need to update the code in a similar way only after updating to 0.9.0

3 Likes

Cool.
Much better now.

So, here we go, 0.9.0 is released:

:bomb: IMPORTANT! A breaking change for the devices attribute of the Connected devices sensor as discussed above. Please, check 2 messages before for the new code examples.

:hourglass: A new possibility - to select a custom update interval for different sensors independently.

:mag: Device trackers got many new updates:

  • you can now disable them;
  • select their own update interval, independent from all other sensors;
  • one nasty bug was fixed, so fewer errors in your HA logs and fewer freezes of the integration.

:open_book: Many code optimizations to faster work on it and decrease the time for bug fixes.

The full release notes are available here: Release 0.9.0 :boom: Breaking change :hourglass: Update intervals for different sensors and device trackers customizations :mag: · Vaskivskyi/ha-asusrouter (github.com).

The update is already available via HACS.

3 Likes

0.9.0 working great, thanks for the update.

Was reading through the GitHub notes and you can add model 4G-AC55U to your list as the component works perfectly on this model with stock firmware (sorry, should have let you know that sooner)

Quick slightly off topic Q…anyone know if is it possible to sort the Flex Table Card by IP Address?

As the same field is used for the three columns I don’t think the sort key will make any difference.
But I believe it always sort the first column (if no other instruction), then you can move IP for the first column. Is that OK?

1 Like

I managed to sort by IP by having a hidden copy of that in the first column.

I still using the old version, but my card looks like this:

type: custom:flex-table-card
title: Connected devices
entities:
  include: sensor.rt_ac88u_connected_devices
columns:
  - data: devices
    name: IP_hidden
    modify: x.split('/')[1]
    hidden: true
  - data: devices
    name: Name
    modify: x.split('/')[2]
  - data: devices
    name: IP
    modify: x.split('/')[1]
  - data: devices
    name: MAC
    modify: x.split('/')[0]
sort_by:
  - devices

With the new format it will look like this:

type: entities
entities:
  - type: custom:fold-entity-row
    padding: 0
    head:
      entity: sensor.rt_ax88u_connected_devices
      icon: mdi:router-wireless
      tap_action:
        action: none
    entities:
      - type: custom:flex-table-card
        sort_by:
          - devices+
        entities:
          include: sensor.rt_ax88u_connected_devices
        columns:
          - data: devices
            name: 'IP_hidden'
            modify: x.ip
            hidden: true
          - data: devices
            name: ' Device Name'
            icon: mdi:devices
            modify: x.name
          - data: devices
            name: ' Address'
            icon: mdi:ip-network
            modify: x.ip
          - data: devices
            name: ' MAC'
            icon: mdi:barcode-scan
            modify: x.mac
        card_mod:
          style: |
            ha-card {
              box-shadow: none;
              background: none;
            }

Yes, @EdwardTFN is right, you can use a hidden column. Also, there is no need to assign a name to it. After upgrading to version 0.9.0 of the integration the code will be like this:

Code
type: entities
entities:
  - type: custom:fold-entity-row
    padding: 0
    head:
      entity: sensor.rt_ax88u_connected_devices
      icon: mdi:router-wireless
      tap_action:
        action: none
    entities:
      - type: custom:flex-table-card
        sort_by:
          - devices+
        entities:
          include: sensor.rt_ax88u_connected_devices
        columns:
          - data: devices
            modify: x.ip
            hidden: true
          - data: devices
            name: ' Device Name'
            icon: mdi:devices
            modify: x.name
          - data: devices
            name: ' Address'
            icon: mdi:ip-network
            modify: x.ip
          - data: devices
            name: ' MAC'
            icon: mdi:barcode-scan
            modify: x.mac
        card_mod:
          style: |
            ha-card {
              box-shadow: none;
              background: none;
            }
2 Likes

Brilliant, thanks to you both for that @Vaskivskyi
@EdwardTFN
Sometimes it’s the obvious solution that’s hardest to find :grin:. Think I need more coffee :coffee:
Thanks again.

1 Like

Thanks for the update! But, for some reason the “Connected Devices” is now showing 0 (see screenshot). And under attributes, there are no devices listed. Any idea as to why this is?

I deleted the “Integration” and re-installed it (Note: I did NOT uninstall the HACS portion; just the Integration) with no effect. I restarted the RPi (running Home Assistant OS) a few times so far without any luck. I’ll try re-installing the HACS Add-On (and the Integration as well) to see if that fixes it.

Edit 1: I just rebooted my ASUS Router to see if maybe a refresh was needed, but unfortunately that wasn’t it either.

Edit 2: For reference, my router model is an RT-AX58U.

Edit 3: I reinstalled the HACS Add-On and then the Integration - no luck. I have a thought as to why I am running into the problem… could it be that enabling ‘Device Trackers’ is required for this to work?

Hey,

I am sorry for this. It is really the case, that if the device tracking is disabled, the connected devices sensor stops working, which I didn’t consider before. The fix will be released today

Version 0.9.1 is already available in HACS and will allow keeping the Connected devices sensor working when device trackers are disabled.

Full changelog: Release 0.9.1 A bugfix and a feature · Vaskivskyi/ha-asusrouter (github.com)

1 Like

@Vaskivskyi Thank you! I updated it and all is working very, very well! I am definitely buying you a cup of coffee (Edit: Just sent you a few cups of coffee :rofl:) - I don’t think I’ve ever seen a developer so active with the community regarding their Integration/Add-On, especially one that specifically updates their project just to fix one thing for ONE individual. Thank you again.

As a side note, I did notice higher than normal CPU usage on the RPi, however I have yet to investigate. It is unlikely that this Integration is the cause, but just wanted to throw it out there. :wink:
I did a reboot of the RPi and the usage dropped back to normal parameters - all is well!

Screenshots:


ASUS Router - Screen Shot 2