AsusWRT Merlin available firmware update notification by Home Assistant

Since version 380.65 AsusWRT Merlin can provide information about availabe firmware update to the Home Assistant.

On the router in location /jffs/scripts You have to create a file update-notification containing:

#!/bin/sh

# Retrieve version
TMPVERS=$(nvram get webs_state_info)
VERS=${TMPVERS:5:3}.${TMPVERS:8:10}
ROUTER_IP=$(nvram get lan_ipaddr)

curl -X POST -H "x-ha-access: HASS-PASSWORD" \
       -H "Content-Type: application/json" \
       -d '{"state": "'$VERS'", "attributes": {"router_ip": "'$ROUTER_IP'"}}' \
       http://HASS_IP:HASS_PORT/api/states/sensor.router_update

and give it permission to run:

chmod +x /jffs/scripts/update-notification

Remember to change HASS-PASSWORD, HASS_IP, HASS_PORT to the correct values.

And in Home Assistant automation:

- alias: Router Update Available Notification
  trigger:
    - platform: state
      entity_id: sensor.router_update
  action:
    service: notify.html5
    data_template: 
      title: 'New firmware version for router'
      message: "There is available new firmware version {{ states.sensor.router_update.state }} for router with IP {{ states.sensor.router_update.attributes.router_ip }}."
    data:
      data:
        tag: 'notification-router-update'
        url: "https://asuswrt.lostrealm.ca/changelog"
3 Likes

Recently upgraded the the latest version of Merlin so I might give this a go! Would be very hand as I’ve always been way behind on latest versions due to no real notification methods! :slight_smile: Thanks for sharing!

Do I need to schedule the update-notification on the router somehow?
How often does it check for new FW?

@frelev Watchdog in router check for new firmware every 48 hours https://www.snbforums.com/index.php?posts/300795

1 Like

Do you know how to fix so it works with HASS running SSL?
Now I get:

curl: (51) SSL: no alternative certificate subject name matches target host name '192.168.1.XX'

This is when executing the script on the router

Try add switch -k for example:

curl -k -X POST -H "x-ha-access: HASS-PASSWORD

That did it, thanks!

This does not work on my setup.
I have change HASS-PASSWORD, HASS_IP, HASS_PORT to the correct values.
and give it permission to run.
But i never get any sensor.router_update in Hass.
My router have had the yellow blinking ! for several days now, but Hass wount pick it up?
Is there any way to debug whats wrong?
Running a RT-AC68U with merlin 380.65_2 (380.65_4 is latest)

Log to the router through SSH and manually run

/jffs/script/update-notification

Any errors?

I get this:

In putty.

Got this in winscp:

I guess i have to get down to the “root” of the asus to dun the script, but i dont seem to be able to get u
out of the /tmp/home/root# folder?

Sorry, should be

/jffs/scripts/update-notification

Same result:

Show me results of

ls /jffs/scripts -l

Do You have checked option “Enable JFFS custom scripts and configs” in router web panel (Administration -> System)?

Yes.

Could You show me

cat /jffs/scripts/update-notification

Here it is.

I added a linebreak at the end of the script.

Will wait and see if that made ant diffrence.

If i run this, sh /jffs/scripts/update-notification i get some sort of result: