running it in HASSIO
Closed this issue · 15 comments
I'm wondering how to make it run in a HASSIO core (Alpine) config....
So far I've been able to install all needed, pair the lock and get it working but then I broke everything trying to run the service as u mentioned but through openrc instead.
Now I'm stopped here and can0t find how to go ahead...
PS: I'm definitely not an expert on any linux distro.... still much to learn
Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/root/RaspiNukiBridge/./__main__.py", line 261, in <module>
web_server.start()
File "/root/RaspiNukiBridge/./__main__.py", line 54, in start
web.run_app(app, host=self._host, port=self._port)
File "/usr/lib/python3.9/site-packages/aiohttp/web.py", line 514, in run_app
loop.run_until_complete(main_task)
File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/usr/lib/python3.9/site-packages/aiohttp/web.py", line 321, in _run_app
await runner.setup()
File "/usr/lib/python3.9/site-packages/aiohttp/web_runner.py", line 279, in setup
self._server = await self._make_server()
File "/usr/lib/python3.9/site-packages/aiohttp/web_runner.py", line 375, in _make_server
await self._app.startup()
File "/usr/lib/python3.9/site-packages/aiohttp/web_app.py", line 417, in startup
await self.on_startup.send(self)
File "/usr/lib/python3.9/site-packages/aiosignal/__init__.py", line 36, in send
await receiver(*args, **kwargs) # type: ignore
File "/root/RaspiNukiBridge/./__main__.py", line 88, in _startup
await self.nuki_manager.start_scanning()
File "/root/RaspiNukiBridge/./nuki.py", line 135, in start_scanning
await self._scanner.start()
File "/usr/lib/python3.9/site-packages/bleak/backends/bluezdbus/scanner.py", line 88, in start
self._bus = await MessageBus(bus_type=BusType.SYSTEM).connect()
File "/usr/lib/python3.9/site-packages/dbus_next/aio/message_bus.py", line 122, in __init__
super().__init__(bus_address, bus_type, ProxyObject)
File "/usr/lib/python3.9/site-packages/dbus_next/message_bus.py", line 85, in __init__
self._setup_socket()
File "/usr/lib/python3.9/site-packages/dbus_next/message_bus.py", line 575, in _setup_socket
raise err
File "/usr/lib/python3.9/site-packages/dbus_next/message_bus.py", line 548, in _setup_socket
self._sock.connect(filename)
FileNotFoundError: [Errno 2] No such file or directory
Is it still working fine if you run the software normally?
Can you please share the script used to autostart it?
Not at all. But I understood yesterday I was following the wrong way…
HASSOS is using docker containers so I’ll move to learn how to build an ADDON from scratch to run your code with all dependencies needed and come back to u in a while during test phase maybe.
I’m learning everything on the job…
your code was perfectly running before I messed up with openrc but anyway an update of HASSOS yesterday overwrote everything I did —> need to build and addon into a container
@ftarolli here's a very basic proof of concept:
https://github.com/f1ren/RaspiNukiBridge/
Tested on my Home Assistant (RPi 4) and it works.
However, would love some help with it:
- Need to simplify setup and configuration. Very complicated right now. I've followed this tutorial. There's a chapter there about Add-On Configuration. So, we should probably implement something of that sort.
- There are too many exceptions and Home Assistant is showing errors. The lock status in Home Assistant is broken.
@f1ren I've finished today my own version and it's under testing.
https://github.com/ftarolli/NukiBridgeAddon
I modified the main.py and the run.sh to do automatic configuration after you entered the lock Mac address.
working fine with my NUKI3.0 on a PI4 out of several exception as u mentioned that are not however stopping the service to work right now.
Like this:
Task exception was never retrieved
future: <Task finished name='Task-13' coro=<Nuki._notification_handler() done, defined at /opt/nuki.py:309> exception=BleakDBusError('org.freedesktop.DBus.Error.NoReply', 'Message recipient disconnected from message bus without replying')>
Traceback (most recent call last):
File "/opt/nuki.py", line 337, in _notification_handler
await self.disconnect()
File "/opt/nuki.py", line 438, in disconnect
await self.manager.start_scanning()
File "/opt/nuki.py", line 135, in start_scanning
await self._scanner.start()
File "/usr/local/lib/python3.9/site-packages/bleak/backends/bluezdbus/scanner.py", line 133, in start
assert_reply(reply)
File "/usr/local/lib/python3.9/site-packages/bleak/backends/bluezdbus/utils.py", line 23, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.freedesktop.DBus.Error.NoReply] Message recipient disconnected from message bus without replying
or this:
Task exception was never retrieved
future: <Task finished name='Task-21' coro=<NukiManager._detected_ibeacon() done, defined at /opt/nuki.py:144> exception=KeyError(76)>
Traceback (most recent call last):
File "/opt/nuki.py", line 146, in _detected_ibeacon
manufacturer_data = advertisement_data.manufacturer_data[76]
KeyError: 76
@dauden1184 any suggestion?
@ftarolli I hope @dauden1184 can be more helpful, but here are my temporary solutions:
- Regarding
BleakDBusError
instart_scanning
, you can check my exponential-backoff solution. It succeeds on second attempt. - On
KeyError: 76
I return quietly.
did the changes u suggested and uploaded to git. I'll have a try tomorrow.
btw, since 1 day now the add-on is working fine without issues while I'm instead annoyed by this log...
2022-04-26 22:19:41.022|I|web_log.py:206|172.30.32.1 [26/Apr/2022:20:19:41 +0000] "GET /list?ts=2022-04-26T20:19:41Z&rnr=xxxxxx&hash=xxxxxxxxxxxxxxxxxxxx HTTP/1.1" 200 543 "-" "python-requests/2.27.1"
I'm wondering if modifying the verbose mode requiring a minimum arg of 0 as below would be the solution
if args.verbose == 0:
logger.setLevel(level=logging.INFO)
logging.getLogger("aiohttp").setLevel(level=logging.INFO) #ERROR
logging.getLogger("bleak").setLevel(level=logging.INFO) #ERROR
elif args.verbose == 1:
logger.setLevel(level=logging.ERROR) #DUBUG
logging.getLogger("aiohttp").setLevel(level=logging.ERROR) #INFO
logging.getLogger("bleak").setLevel(level=logging.ERROR) #INFO
elif args.verbose == 2:
logger.setLevel(level=logging.DEBUG)
logging.getLogger("aiohttp").setLevel(level=logging.DEBUG)
logging.getLogger("bleak").setLevel(level=logging.DEBUG)
or this:
Task exception was never retrieved
future: <Task finished name='Task-21' coro=<NukiManager._detected_ibeacon() done, defined at /opt/nuki.py:144> exception=KeyError(76)>
Traceback (most recent call last):
File "/opt/nuki.py", line 146, in _detected_ibeacon
manufacturer_data = advertisement_data.manufacturer_data[76]
KeyError: 76@dauden1184 any suggestion?
What nuki device are you using? Is it a lock? what version?
did the changes u suggested and uploaded to git. I'll have a try tomorrow. btw, since 1 day now the add-on is working fine without issues while I'm instead annoyed by this log...
2022-04-26 22:19:41.022|I|web_log.py:206|172.30.32.1 [26/Apr/2022:20:19:41 +0000] "GET /list?ts=2022-04-26T20:19:41Z&rnr=xxxxxx&hash=xxxxxxxxxxxxxxxxxxxx HTTP/1.1" 200 543 "-" "python-requests/2.27.1"
I'm wondering if modifying the verbose mode requiring a minimum arg of 0 as below would be the solution
if args.verbose == 0:
logger.setLevel(level=logging.INFO)
logging.getLogger("aiohttp").setLevel(level=logging.INFO) #ERROR
logging.getLogger("bleak").setLevel(level=logging.INFO) #ERROR
elif args.verbose == 1:
logger.setLevel(level=logging.ERROR) #DUBUG
logging.getLogger("aiohttp").setLevel(level=logging.ERROR) #INFO
logging.getLogger("bleak").setLevel(level=logging.ERROR) #INFO
elif args.verbose == 2:
logger.setLevel(level=logging.DEBUG)
logging.getLogger("aiohttp").setLevel(level=logging.DEBUG)
logging.getLogger("bleak").setLevel(level=logging.DEBUG)
If the flag --verbose
is not specified, by default the value is 0.
Is that what you meant?
I'm using a PI4 with HASSIO.
Core 2022.4.7
Supervisor 2022.04.0
Nuki lock 3.0
ABOUT VERBOSE:
I saw it. In fact I was thinking to changed the first line of the "if" sentence to require an argument (0/1/2) to log something otherwise proceed smoothly...
What do I think?
My Home Assitant Addon is quite stable now.
It even finds the MAC address for you :)
Will merge the stuff in the next days, sorry but i was on vacation 😅
My Home Assitant Addon is quite stable now.
It even finds the MAC address for you :)
I tried your add-on in hassio, but it doesn't work ==>
022-05-17 14:38:24.987|I|nuki.py:193|Stop scanning 2022-05-17 14:38:24.987|I|nuki.py:200|Error while stop scanning. Scan was probably not started. 2022-05-17 14:38:24.987|E|nuki.py:201|'NoneType' object has no attribute 'call' Traceback (most recent call last): File "/opt/./nuki.py", line 195, in stop_scanning await self._scanner.stop() File "/usr/local/lib/python3.9/site-packages/bleak/backends/bluezdbus/scanner.py", line 169, in stop reply = await self._bus.call( AttributeError: 'NoneType' object has no attribute 'call' 2022-05-17 14:38:24.990|I|nuki.py:591|Nuki connecting
Ps: sorry to hijack this discussion, @f1ren, I cannot post this error in your git!