- Sensors:
- Wireless clients counters
- Number of connected mesh peers
- Signal strength of mesh links
mwan3
interface online ratio- WAN interfaces Rx&Tx bytes counters (if configured)
- Switches:
- Control WPS status
- Binary sensors:
mwan3
connectivity status
- Services:
- Reboot device:
openwrt.reboot
- Execute arbitrary command:
openwrt.exec
(see the configuration below)
- Reboot device:
-
OpeWrt device(s):
- Make sure that
uhttpd uhttpd-mod-ubus rpcd
packages are installed (if you use custom images)- If you use mesh networks, install
rpcd-mod-iwinfo
package
- If you use mesh networks, install
- Make sure that
ubus
is available via http using the manual: https://openwrt.org/docs/techref/ubus- To make it right, please refer to the
Ubus configuration
section below
- To make it right, please refer to the
- Make sure that
-
Home Assistant:
- Add this repo as a custom integration using HACS
- Restart server
- Go to
Integrations
and add a newOpenWrt
integration
- Create new file
/usr/share/rpcd/acl.d/hass.json
:
{
"hass": {
"description": "Home Assistant OpenWrt integraion permissions",
"read": {
"ubus": {
"network.wireless": ["status"],
"network.device": ["status"],
"iwinfo": ["info", "assoclist"],
"hostapd.*": ["get_clients", "wps_status"],
"system": ["board"],
"mwan3": ["status"]
},
},
"write": {
"ubus": {
"system": ["reboot"],
"hostapd.*": ["wps_start", "wps_cancel"]
}
}
}
}
- Add new system user
hass
(or do it in any other way that you prefer):- Add line to
/etc/passwd
:hass:x:10001:10001:hass:/var:/bin/false
- Add line to
/etc/shadow
:hass:x:0:0:99999:7:::
- Change password:
passwd hass
- Add line to
- Edit
/etc/config/rpcd
and add:
config login
option username 'hass'
option password '$p$hass'
list read hass
list read unauthenticated
list write hass
- Restart rpcd:
/etc/init.d/rpcd restart
In order to allow ubus/rpcd execute a command remotely, the command should be added to the permissions ACL file above. The extra configuration could look like below (gives permission to execute uptime
command):
{
"hass": {
"write": {
"ubus": {
/* ... */
"file": ["exec"]
},
"file": {
/* ... */
"/usr/bin/uptime": ["exec"]
}
},
}
}