Open redfirebrooks opened 3 years ago
@redfirebrooks
Sorry for the late reply!
This is a ongoing plague with imports on raspbian, domoticz can't find the same modules as the command line.
Try switching to the debug branch, it is the same version as master (0.10.6) with import error handling disabled. It will fail just like the regular master, but should provide a bit more information and context, hopefully this will enable us to find out why it fails...
I have a similar issue it seems: python3 plugin.py list
shows all my devices, and I can even control the lights from the command line, but Domoticz doesn't see any Tradfri devices. I have switched to the debug branch, and see this in my Domoticz log, repeatedly:
2021-02-03 00:52:43.412 Error: IKEA-Tradfri hardware (11) thread seems to have ended unexpectedly
Apart from the startup message, no other log info is produced. It seems that Domoticz doesn't do much logging if a plugin dies a horrible death.
In my case, it turns out that domoticz is running as root despite being started with start-stop-daemon --chuid
, which means that my user-installed tradfricoap
library wasn't accessible. I haven't yet tracked down the root cause of why chuid is being ignored. In my case, a good test to see if tradfricoap was installed successfully was to run sudo su - -c "python3 $HOME/domoticz/plugins/IKEA-Tradfri/plugin.py list"
. I will eventually replace the domoticz startup script with a systemd unit file; this is not the first time start-stop-daemon
has surprised me. Ubuntu 20.04, but probably not release dependent.
Anyway, I do see my Tradfri devices in Domoticz now.
Hi people, I fixed this error in my Pi/Domoticz
I installed Tradfricoap local:
$ cd domoticz/plugins/IKEA-Tradfri
$ git clone https://github.com/moroen/tradfricoap.git
Now i got the error that Tradfricoap is 2 times on my machine. So uninstall it
$ cd domoticz/plugins
$ pip3 uninstall tradfricoap
$ cd IKEA-Tradfri
$ python3 plugin.py version
IKEA Tradfri Plugin: 0.10.6
Tradfricoap: 0.0.17
Py3coap: 0.9.2
coapcmd: Not found (Looking for /home/pi/domoticz/plugins/IKEA-Tradfri/bin/coapcmd).
And restarted the plugin in Domoticz and my IKEA-Tradfri plugin is running again :)
I'm working on a fresh install of domoticz in an proxmox VM with debian, and experience the same error. python3 plugin.py list does indeed list my devices. But Domoticz cannot communicatie with coap.
I use the py3coap module. I noticed the following:
So my conclusion would be something like: Tradfri-coap should be run as Root. What are your thoughts on this? Any idea how to check this?
Update: all previous suggestions didn't work for me, but I found te following sollution:
Follow the install manual exactly as described, but everything with sudo. Everything works as expected. Allthough, my Domoticz runs as root. Not my preverence.
@ZatarraNL
You should not run domoticz as root. On most linux systems, including debian, adding the user to the plugdev group allows that user's processes to access the USB-devices:
sudo usermod -aG plugdev $USER
will add your current user to this group, and allow domoticz started as that user to access the UBS zwave stick. Remember to log out and log in again to activate the membership in the group.
So if you're able to get tradfri to work when running domoticz as user Zatarra, i really recommend going this route!
As a general rule, nothing in userspace should be run as root. Bad code in such a program, malicious or unintended, could really wreck havoc on your system, or present a serious security threat!
I try to make py3coap, tradfricoap and the plugin, as safe as possible, but I really would not recommend running either as root, so no, tradfri-coap should definitely not be run as root!
If you really want to, installing py3coap with the root user should solve the issue you're having:
$ sudo pip3 install py3coap tradfricoap
The issue that I ran into may be the same one that @ZatarraNL ran in to: the init.d script that comes with domoticz does try to start domoticz as a non-root user with start-stop-daemon --chuid $USERNAME, but for some reason the chuid is ignored. This may well be a limitation of systemd. I have not yet come around to rewriting the startup script to a native systemd unit, which I expect would solve my issue.
@driehuis
Perhaps you could use my systemd unit-file as a starting point?
[Unit]
Description=Domoticz Home Automation
After=network.target ikea-tradfri.service
[Service]
User=moroen
WorkingDirectory=/opt/domoticz
ExecStart=/opt/domoticz/domoticz -www 8080 -sslwww 443
KillMode=process
Restart=on-failure
Nice=-18
[Install]
WantedBy=multi-user.target
With this, installing py3coap and tradfricoap as moroen, and using the --user option of pip3, domoticz finds py3coap and tradfricoap.
Ooh, lovely! I do not have a separate ikea-tradfri.service, but this is an excellent starting point. How did you solve using port 443 under a non-root user? I was planning to put nginx or lighttpd in front of domoticz for that reason.
@ZatarraNL
You should not run domoticz as root. On most linux systems, including debian, adding the user to the plugdev group allows that user's processes to access the USB-devices:
sudo usermod -aG plugdev $USER
I agree, but the /etc/init.d/domoticz.sh seems to runs domoticz as root. This is despite that the domoticz.sh describes Zatarra as user. I find it surprizing that domoticz runs in root out of the box...
The systemd solution does run domoticz as Zatarra. But somehow adding the user Zatarra to the dialout group still gives me problems with the zwave-stick. I'll try to find a solution some other day.
Thanks for your effort with this plugin. I've used it so far for over a year.
@driehuis
Ooh, lovely! I do not have a separate ikea-tradfri.service, but this is an excellent starting point. How did you solve using port 443 under a non-root user? I was planning to put nginx or lighttpd in front of domoticz for that reason.
I didn't... I don't expose domoticz (or anything on my network) to the outside, so I don't care that SSL is not working... But I would imagine it should be possible to use a non-privileged port for SSL, by changing the following line in the unit file:
ExecStart=/opt/domoticz/domoticz -www 8080 -sslwww 8090
Hello I have errors after updating the plugin
Raspbian GNU/Linux 10 (buster) Domoticz V2020.2 (c)2012-2020 GizMoCuz Build Hash: b63341bc0, Date: 2020-04-26 13:47:55 (IKEA TRADFRI) Initialized version 0.10.6, author 'moroen'
Already tried https://github.com/moroen/IKEA-Tradfri-plugin/wiki/Common-errors but no improvement, still have the errors...
Then I've checked the version :
but coapcmd was alreday installed (under sudo I guess)...
so I uninstalled it
to re install it (with the -U option)
then to be sure to use py3coap
pi@domoticz:~/domoticz/plugins/IKEA-Tradfri $ python3 plugin.py config api py3coap
So I made a test
Everything seems to be OK but I still have the errors in Domoticz logs...