Basic control of OpenWRT?

I run a hass.io on Pi4, and I have an OpenWRT WiFi router. I’d like to be able to do very simple automations like disabling a certain SSID on the router when other events happen. (Trying to manage screentime for my kid so the kiddo doesn’t just use their Kindle for shows/games when the TV goes off).

Has anyone already figured this out? I didn’t want to reinvent the wheel. I can think of a few ways to attempt it but am only a few weeks into Home Assistant.

Would also be interested in something like that :slight_smile:

Turns out HACS has an “SSH Sensor” that’s intended to run a single command in SSH on any device, and put the output into a sensor. I see no reason I can’t use a couple of those sensors to fire my .sh scripts on the router that activate or deactivate the SSID. (Actually my scripts just add or remove it from the guest VLAN, so you can’t reach anything in the removed state.) I can share my shellscripts if you need a working example.

 -----------------------------------------------------
 OpenWrt .....
 -----------------------------------------------------
root@MarsNet:~# cat guestdown.sh
uci set wireless.@wifi-iface[2].network='Guest'.disabled='1'
uci commit wireless
wifi down; wifi up

root@MarsNet:~# cat guestup.sh
uci delete wireless.@wifi-iface[2].network='Guest'.disabled='1'
uci set wireless.@wifi-iface[2].network='Guest'
uci commit wireless
wifi down; wifi up
root@MarsNet:~#
2 Likes

I do something very similar using NodeRED, SSH into the router to activate a firewall rule that blocks LGTV, Apple TV, etc. I’ve set this up on a timer so that I can open the firewall for a defined period of time. It works OK… but I don’t (yet) have a good mechanism for reflecting the status of the firewall in HomeAssistant. I recently found the https://github.com/kvj/hass_openwrt project and I’m curious about using it to strengthen the integration betwen HA and the router (running OpenWRT)

1 Like