Error setting up platform ubus
Traceback (most recent call last):
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/device_tracker/init.py”, line 181, in async_setup_platform
platform.get_scanner, hass, {DOMAIN: p_config})
File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/device_tracker/ubus.py”, line 43, in get_scanner
scanner = DnsmasqUbusDeviceScanner(config[DOMAIN])
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/device_tracker/ubus.py”, line 148, in init
super(DnsmasqUbusDeviceScanner, self).init(config)
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/device_tracker/ubus.py”, line 87, in init
self.url, self.username, self.password)
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/device_tracker/ubus.py”, line 233, in _get_session_id
return res[“ubus_rpc_session”]
TypeError: ‘NoneType’ object is not subscriptable
do you solove it?
Are you using Hassio? If the answer is yes, you do not have a work around.
no,i use the homeassistant on ubuntu
Then the solution is here:
use this method?
I . Copy your CA cert (make sure file extension is .crt) to /usr/share/ca-certificates/
2. $ sudo update-ca-certificates (make sure you see “1 added” in the output
3. Set environment variable REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt when you starts home assistant.The “requests” library used for making HTTPS requests to openwrt seems to bundle its own CA bundle by default and this should override the behavior.
thank you
I believe so, I’ve never done it. Just found it in that thread.
but my problem is not showing SSL problem…
Did you follow the installation guide for the RPC package for OpenWRT?
Namely:
Before this scanner can be used you have to install the ubus RPC package on OpenWRT:
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.
{
"user": {
"description": "Read only user access role",
"read": {
"ubus": {
"*": [ "*" ]
},
"uci": [ "*" ]
},
"write": {}
}
}
Restart the services.
# /etc/init.d/rpcd restart && /etc/init.d/uhttpd restart
Check if the file namespaces is registered with the RPC server.
# ubus list | grep file
file
yes ,i have do that
I’ve been struggling with this since upgrading to a newer version of OpenWrt. For me what solved it was installing opkg install uhttpd-mod-ubus
. I came to this conclusion because the POST to /ubus on my router would return a 404.
It would be a big improvement in troubleshootability of this code if a non 2xx return of the RPC call would be logged as an error and not some exception that something is NoneType somewhere downstream.
I’ve been struggling with this since upgrading to a newer version of OpenWrt. For me what solved it was installing opkg install uhttpd-mod-ubus.
I have the same problem now after upgrading Open WRT from 17.x to 18.x. How did you exactly solve it? Just installing utthpd-mod-ubus? I tried that but without any result. Did you change or tweak anything else?
I noticed that the upgrade affects the installation in two ways: all the xtra packages get uninstalled, the acl file in /usr/share/rpcd/acl.d/user.json
is deleted. You therefore have to start from scratch. On top of that 18.x seems to require the uhttpd-mod-ubus
package.
One small caveat that tripped me up when I upgraded to the next minor version: you need to restart the services yourself by running /etc/init.d/rpcd restart && /etc/init.d/uhttpd restart
after installing packages.
Another trick that helped me to arrive to this solution: the call that hass does to openwrt can be done manually using curl:
curl --data-ascii '{"jsonrpc": "2.0", "id": 1, "method": "call", "params": ["00000000000000000000000000000000", "session", "login", {"username": "root", "password": "<insert your password>"}]}' http://<router ip>/ubus/ -v
Thanks! I forgot to restart the services…
I will submit an issue so they can change the documentation about UBUS and HA.
I was still looking into hardening the connection to ubus by limiting network access and shrinking the permissions to the minimum, because IMHO the description on the HA component is not really secure.
Just want to confirm that rf3141 solution worked for me. When I upgraded to OpenWRT 18.06 ubus to HA stopped working. I then upgraded to HA 0.77.3 but it did not solve the problem.
After:
opkg install uhttpd-mod-ubus
/etc/init.d/rpcd restart && /etc/init.d/uhttpd restart
It worked again.
Same issue when upgrading to 18.06. uhttpd-mod-ubus install seems to have resolved.
What is the expected response?
Trying to debug my setup, this is what I get:
* Trying 192.168.0.1...
* TCP_NODELAY set
* Connected to 192.168.0.1 (192.168.0.1) port 80 (#0)
> POST /ubus/ HTTP/1.1
> Host: 192.168.0.1
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Length: 158
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 158 out of 158 bytes
< HTTP/1.1 404 Not Found
< Connection: Keep-Alive
< Transfer-Encoding: chunked
< Keep-Alive: timeout=20
< Content-Type: text/html
<
* Connection #0 to host 192.168.0.1 left intact
Anything in the 200 range. I will run the call on my setup in the morning.
I have noticed that the installed packages are gone when you upgrade openwrt. I have had to reinstall the packages after each upgrade. Maybe that is the reason you get a not found?
Thank you for your reply!
Turns out I did not have all the required packages installed. When I wasn’t able to install uhttpd-mod-ubus
("Unknown package
") I somehow assumed that it was no longer required for 19.x. Turns out I first had to update opkg.
I guess that is going to be first contribution to the documentation