muniter / halinuxcompanion

HomeAssistant Linux Companion
MIT License
54 stars 6 forks source link

[BUG] #32

Open MatzeP opened 5 days ago

MatzeP commented 5 days ago

Hi, I have add you service, but get these error

sudo journalctl -u halinuxcompanion.service

Nov 07 21:54:11 MatzePC systemd[1]: halinuxcompanion.service: Scheduled restart job, restart counter is at 9. Nov 07 21:54:11 MatzePC systemd[1]: Started halinuxcompanion.service - Home Assistant Linux Companion. Nov 07 21:54:11 MatzePC python[21516]: INFO:halinuxcompanion:Reading configuration file config.json Nov 07 21:54:11 MatzePC python[21516]: Traceback (most recent call last): Nov 07 21:54:11 MatzePC python[21516]: File "", line 198, in _run_module_as_main Nov 07 21:54:11 MatzePC python[21516]: File "", line 88, in _run_code Nov 07 21:54:11 MatzePC python[21516]: File "/home/matthias/halinuxcompanion/halinuxcompanion/main.py", line 104, in Nov 07 21:54:11 MatzePC python[21516]: loop.run_until_complete(main()) Nov 07 21:54:11 MatzePC python[21516]: File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete Nov 07 21:54:11 MatzePC python[21516]: return future.result() Nov 07 21:54:11 MatzePC python[21516]: ^^^^^^^^^^^^^^^ Nov 07 21:54:11 MatzePC python[21516]: File "/home/matthias/halinuxcompanion/halinuxcompanion/main.py", line 69, in main Nov 07 21:54:11 MatzePC python[21516]: await bus.init() Nov 07 21:54:11 MatzePC python[21516]: File "/home/matthias/halinuxcompanion/halinuxcompanion/dbus.py", line 86, in init Nov 07 21:54:11 MatzePC python[21516]: self.session = await MessageBus(bus_type=BusType.SESSION).connect() Nov 07 21:54:11 MatzePC python[21516]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Nov 07 21:54:11 MatzePC python[21516]: File "/home/matthias/halinuxcompanion/.venv/lib/python3.12/site-packages/dbus_next/aio/message_bus.py", line 122, in init Nov 07 21:54:11 MatzePC python[21516]: super().init(bus_address, bus_type, ProxyObject) Nov 07 21:54:11 MatzePC python[21516]: File "/home/matthias/halinuxcompanion/.venv/lib/python3.12/site-packages/dbus_next/message_bus.py", line 72, in init Nov 07 21:54:11 MatzePC python[21516]: get_bus_address(bus_type)) Nov 07 21:54:11 MatzePC python[21516]: ^^^^^^^^^^^^^^^^^^^^^^^^^ Nov 07 21:54:11 MatzePC python[21516]: File "/home/matthias/halinuxcompanion/.venv/lib/python3.12/site-packages/dbus_next/_private/address.py", line 98, in get_bus_address Nov 07 21:54:11 MatzePC python[21516]: return get_session_bus_address() Nov 07 21:54:11 MatzePC python[21516]: ^^^^^^^^^^^^^^^^^^^^^^^^^ Nov 07 21:54:11 MatzePC python[21516]: File "/home/matthias/halinuxcompanion/.venv/lib/python3.12/site-packages/dbus_next/_private/address.py", line 54, in get_session_bus_address Nov 07 21:54:11 MatzePC python[21516]: home = os.environ['HOME'] Nov 07 21:54:11 MatzePC python[21516]: ~~^^^^^^^^ Nov 07 21:54:11 MatzePC python[21516]: File "", line 685, in getitem Nov 07 21:54:11 MatzePC python[21516]: KeyError: 'HOME' Nov 07 21:54:11 MatzePC python[21516]: ['/home/matthias/halinuxcompanion', '/usr/lib/python312.zip', '/usr/lib/python3.12', '/usr/lib/python3.12/lib-dynload', '/home/matthias/halinuxcompanion/.venv/lib/pytho> Nov 07 21:54:11 MatzePC systemd[1]: halinuxcompanion.service: Main process exited, code=exited, status=1/FAILURE Nov 07 21:54:11 MatzePC systemd[1]: halinuxcompanion.service: Failed with result 'exit-code'.

My Service is: [Unit] Description=Home Assistant Linux Companion Documentation=https://github.com/muniter/halinuxcompanion After=networking.target

[Service] WorkingDirectory=/home/matthias/halinuxcompanion/ ExecStart=/home/matthias/halinuxcompanion/.venv/bin/python -m halinuxcompanion -c config.json Restart=always RestartSec=30

[Install] WantedBy=default.target

slovdahl commented 4 days ago

Where did you put the systemd unit? I have put it in ~/.config/systemd/user/ and start it using systemctl --user start halinuxcompanion.service. I haven't tried but putting it in e.g. /etc/systemd/system/ might not work with the sample file. The docs could probably be made more clear about this (if this is the problem).