--- layout: page title: "OpenWRT (ubus)" description: "Instructions on how to integrate OpenWRT routers into Home Assistant." date: 2015-03-23 19:59 sidebar: true comments: false sharing: true footer: true logo: openwrt.png ha_category: Presence Detection ha_release: 0.7.6 --- _This is one of multiple ways we support OpenWRT. For an overview, see [openwrt](/components/device_tracker.openwrt/)._ This is a presence detection scanner for OpenWRT using [luci](http://wiki.openwrt.org/doc/techref/luci).
This component requires a [workaround](https://github.com/home-assistant/home-assistant/issues/1258#issuecomment-252469880) when using luci with HTTPS and a self-signed certificate.
Before this scanner can be used you have to install the luci RPC package on OpenWRT: ```bash # opkg install luci-mod-rpc ``` To use this device tracker in your installation, add the following to your `configuration.yaml` file: ```yaml # Example configuration.yaml entry device_tracker: - platform: luci host: ROUTER_IP_ADDRESS username: YOUR_ADMIN_USERNAME password: YOUR_ADMIN_PASSWORD ``` Configuration variables: - **host** (*Required*): The IP address of your router, e.g. `192.168.1.1`. - **username** (*Required*): The username of an user with administrative privileges, usually `admin`. - **password** (*Required*): The password for your given admin account. See the [device tracker component page](/components/device_tracker/) for instructions how to configure the people to be tracked.Some installations have [a small bug](https://github.com/openwrt/luci/issues/576). The timeout for luci RPC calls is not set and this makes the call fail.
)._ This is a presence detection scanner for [OpenWRT](https://openwrt.org/) using [ubus](http://wiki.openwrt.org/doc/techref/ubus). It scans for changes in `hostapd.*`, which will detect and report changes in devices connected to the access point on the router. Before this scanner can be used you have to install the ubus RPC package on OpenWRT: ```bash opkg install rpcd-mod-file ``` And create a read-only user to be used by setting up the ACL file `/usr/share/rpcd/acl.d/user.json`. ```json { "user": { "description": "Read only user access role", "read": { "ubus": { "*": [ "*" ] }, "uci": [ "*" ] }, "write": {} } } ``` Restart the services. ```bash # /etc/init.d/rpcd restart && /etc/init.d/uhttpd restart ``` Check if the `file` namespaces is registered with the RPC server. ```bash # ubus list | grep file file ``` After this is done, add the following to your `configuration.yaml` file: ```yaml # Example configuration.yaml entry device_tracker: - platform: ubus host: ROUTER_IP_ADDRESS username: YOUR_ADMIN_USERNAME password: YOUR_ADMIN_PASSWORD ``` Configuration variables: - **host** (*Required*): The IP address of your router, eg. 192.168.1.1. - **username** (*Required*): The username of an user with administrative privileges, usually *root*. - **password** (*Required*): The password for your given account. - **dhcp_software** (*Optional*): The DHCP software used in your router: `dnsmasq`, `dhcpd`, or `none`. Defaults to `dnsmasq`. See the [device tracker component page](/components/device_tracker/) for instructions how to configure the people to be tracked. ## Troubleshooting If you find that this never creates `known_devices.yaml`, or if you need more information on the communication chain between Home Assistant and OpenWRT, follow these steps to grab the packet stream and gain insight into what's happening. ### Increase Log Level 1. On your Home Assistant device, stop Home Assistant 2. Adjust `configuration.yaml` to log more detail for the `device_tracker` component ```yaml logger: default: warn logs: homeassistant.components.device_tracker: debug ``` 3. In another window, tail the logfile in the configuration directory: ``` $ tail -f home-assistant.log | grep device_tracker ``` 4. If you see a python stack trace like the following, check your configuration for correct username/password. ``` 17-04-28 10:43:30 INFO (MainThread) [homeassistant.loader] Loaded device_tracker from homeassistant.components.device_tracker 17-04-28 10:43:30 INFO (MainThread) [homeassistant.loader] Loaded device_tracker.ubus from homeassistant.components.device_tracker.ubus 17-04-28 10:43:30 INFO (MainThread) [homeassistant.setup] Setting up device_tracker 17-04-28 10:43:31 INFO (MainThread) [homeassistant.components.device_tracker] Setting up device_tracker.ubus 17-04-28 10:43:31 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform ubus File "/opt/homeassistant/venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/__init__.py", line 152, in async_setup_platform File "/opt/homeassistant/venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/ubus.py", line 36, in get_scanner File "/opt/homeassistant/venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/ubus.py", line 58, in __init__ File "/opt/homeassistant/venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/ubus.py", line 156, in _get_session_id File "/opt/homeassistant/venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/ubus.py", line 147, in _req_json_rpc 17-04-28 10:43:31 INFO (MainThread) [homeassistant.core] Bus:Handling