Sorry, looking at this again, it appears I might have led you out on somewhat of a wild goose-chase...Nopea wrote: ↑Sunday 08 December 2019 22:57 Running a fresh install of Buster on a Raspberry Pi 3 and following the guidelines in this thread I get the following. Any suggestions how to proceed? What version of python should one be using?
root@raspberrypi:/home/pi/domoticz/plugins/IKEA-Tradfri# python -V
Python 3.8.0
root@raspberrypi:/home/pi/domoticz/plugins/IKEA-Tradfri# python tradfricoap.py config xxxxxxxxxxxxxxxxx yyyyyyyyyyyyyyyyyyyyyy
Traceback (most recent call last):
File "tradfricoap.py", line 5, in <module>
from tradfri.config import get_config, host_config
File "/home/pi/domoticz/plugins/IKEA-Tradfri/tradfri/config.py", line 1, in <module>
import appdirs, logging, os, json
ModuleNotFoundError: No module named 'appdirs'
root@raspberrypi:/home/pi/domoticz/plugins/IKEA-Tradfri# python3 -V
Python 3.7.3
root@raspberrypi:/home/pi/domoticz/plugins/IKEA-Tradfri# python3 tradfricoap.py config xxxxxxxxxxxxx yyyyyyyyyyyyyyyyy
2019/12/08 21:53:57 COAP DTLS Error: Handshake timeout
Traceback (most recent call last):
File "tradfricoap.py", line 357, in <module>
create_ident(args.IP, args.KEY, CONFIGFILE)
File "/home/pi/domoticz/plugins/IKEA-Tradfri/tradfri/gw.py", line 17, in create_ident
uri, payload=payload, method=pycoap.POST, ident="Client_identity", key=key
File "/usr/lib/python3.7/json/__init__.py", line 341, in loads
raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType
You actually have two separate issues here, due to having two different python interpreters. I see that when using python (i.e. 3.8.0 on you system) the Modules are not installed, I would guess that your pip3 is using the python3 interpreter (3.7.3).
The second, and more pertinent issue is the "COAP DTLS Error: Handshake timeout" - error. That shows that the modules are installed and that tradfricoap.py tries to connect to your gateway, but fails to establish a connection. Check the ip and gateway key!
A bit of friendly advice, and I really don't want to come across as a "besserwisser" here, but unless it's by design, you really should fix your python installation! Having two (or more) separate version 3.x interpreters installed in the system path is asking for trouble...
Installing modules using pip might become a nightmare and more importantly, you need to determine which python interpreter domoticz is actually using, and make sure that the needed modules are installed for that interpreter. You might end up in a situation where tradfricoap.py works from the command line, but still fails from domoticz, because the command line is using one interpreter and domoticz another!
Traditionally python refers to a version 2.x interpreter and python3 to a 3.x, and thus pip is used for installing modules for the 2.x interpreter and pip3 for the 3.x version. Now, this might change when python 2x. reach end of life 01.01.2020... If you actually need to have more than one version 3.x interpreter available on your system, take a look at pyenv (https://github.com/pyenv/pyenv)!
Unless you really need the latest python, I would stick to the python3 version available as a package in raspbian, on buster that is 3.7.3 which works for tradfri and most other python3 applications...
Regards,
M