Hi all,
don’t want to go down the ubus path (and/or use those horrible official HA integrations).
I want to control my wifi ssids via home assistant using shell commands via ssh. Does anyone by any chance have a working config template for that? I played around a bit but without success. Basically I just need a switch for every ssid. On/Off. That’s it.
Thank you ![]()
- switch:
name: your_wifi
command_on: "ssh -i /config/ssh_keys/yourkey -o 'StrictHostKeyChecking=no' [email protected] 'uci -q set wireless.@wifi-iface[-1].disabled=0&& uci commit wireless; wifi reload'"
command_off: "ssh -i /config/ssh_keys/yourkey -o 'StrictHostKeyChecking=no' [email protected] 'uci -q set wireless.@wifi-iface[-1].disabled=1&& uci commit wireless; wifi reload'"
command_state: "ssh -i /config/ssh_keys/yourkey -o 'StrictHostKeyChecking=no' [email protected] 'uci get wireless.@wifi-iface[-1].disabled'"
value_template: "{{ value == '0' }}"
here is what I use for openwrt router. you will need your own keys and to know which wifi-iface number you are looking to turn off specific ssid.
- switch:
name: 5_8ghz_wifi
command_on: "ssh -i /config/ssh_keys/yourkey -o 'StrictHostKeyChecking=no' [email protected] 'uci set wireless.radio0.disabled=0; uci commit wireless; wifi reload'"
command_off: "ssh -i /config/ssh_keys/yourkey -o 'StrictHostKeyChecking=no' [email protected] 'uci set wireless.radio0.disabled=1; uci commit wireless; wifi reload'"
command_state: "ssh -i /config/ssh_keys/yourkey -o 'StrictHostKeyChecking=no' [email protected] 'uci get wireless.radio0.disabled'"
value_template: "{{ value == '0' }}"
This command is to toggle the 5.8ghz wifi.
thank you that did the trick! its worth mentioning that its generally not a good idea to connect HA to the router like this from a safety perspective but at least it works. I used wifinet instead of radio to control specific ssids intead of turning the entire radio on/off