pytradfri.error.RequestTimeout
miskor-bgd opened this issue · comments
Where are you using pytradfri (eg stand-alone, Home Assistant etc)
stand-alone
Version of pytradfri
pytradfri-7.0.6
Backend used (aiocoap, libcoap)
libcoap
Expected behaviour
list of commands?
Actual behaviour
(parts are obfuscated)
xxx@xxxx-vm:~/libcoap$ python3 -i -m pytradfri 192.168.x.y
DEBUG:pytradfri.util:JSON file not found: tradfri_standalone_psk.conf
Please provide the 'Security Code' on the back of your Tradfri gateway: ............
DEBUG:pytradfri.util:JSON file not found: tradfri_standalone_psk.conf
DEBUG:pytradfri.api.libcoap_api:Executing 192.168.x.y post ['15011', '9063']: {'9090': 'yyyyyyy'}
DEBUG:pytradfri.api.libcoap_api:Received: {"9091":"xxxxxx","9029":"1.13.0021"}
Generated PSK: xxxxxx
DEBUG:pytradfri.api.libcoap_api:Executing 192.168.x.y get ['15001']
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/miskor/.local/lib/python3.8/site-packages/pytradfri/main.py", line 73, in
devices_commands = api(gateway.get_devices())
File "/home/miskor/.local/lib/python3.8/site-packages/pytradfri/api/libcoap_api.py", line 94, in request
return self._execute(api_commands, timeout=timeout)
File "/home/miskor/.local/lib/python3.8/site-packages/pytradfri/api/libcoap_api.py", line 84, in _execute
raise RequestTimeout() from None
pytradfri.error.RequestTimeout
I've rebooted tradfri gw, same error still present..
I do have 56 devices registered, maybe this is causing a timeout?
coap-client seems to work ok:
$ coap-client -m post -u "Client_identity" -k ".........." -e "{"9090":"admin"}" "coaps://192.168.x.y:5684/15011/9063"
{"9091":"xxxxxxxxxxxxxxx","9029":"1.13.0021"}
So tradfri gw sw version is 1.13.0021, maybe this can be the issue as well?
but coap-client "Get a list of all devices" command also works ok:
$ coap-client -m get -u "xxxxxxx" -k "yyyyyyyy" "coaps://192.168.x.y:5684/15001"
[65549,65606,65575,65621,65545,65565,65613,65558,65623,65616,65624,65538,65590,65589,65567,65561,65598,65611,65591,65597,65610,65605,65620,65587,65618,65566,65540,65626,65568,65588,65553,65560,65614,65573,65571,65572,65570,65601,65617,65619,65546,65581,65576,65607,65543,65577,65539,65609,65602,65550,65580,65548,65574,65579,65541,65578]
Is there a file tradfri_standalone_psk.conf created in your run folder? It might be a rights-issue that the file containing the credentials is not written to disk?
yes, it is created with "identity" and "key" fields and permissions are 664 so it should be ok
Does it work with aiocoap-client
?
Create tradfri_standalone_psk.json
using the values from tradfri_standalone_psk.conf
instead of uppercase placeholders:
{
"coaps://IP:5684/*": {
"dtls": {
"client-identity": {
"ascii": "IDENTITY"
},
"psk": {
"ascii": "KEY"
}
}
}
}
Then run aiocoap-client --credentials tradfri_standalone_psk.json coaps://IP:5684/15001
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days
I have the same issue. I have tried to reset/restart the gateway without any luck.
Installed libcoap
without any issues with install-coap-client.sh
tradfri_standalone_psk.conf
is there with the correct values.
Ikea gateway responds to pings. Ikea gateway version==1.17.33
xxx@xxx:~/pytradfri$ ping 192.168.x.x
PING 192.168.x.x (192.168.x.x) 56(84) bytes of data.
64 bytes from 192.168.x.x: icmp_seq=1 ttl=64 time=2.12 ms
64 bytes from 192.168.x.x: icmp_seq=2 ttl=64 time=30.5 ms
64 bytes from 192.168.x.x: icmp_seq=3 ttl=64 time=1.12 ms
^C
--- 192.168.x.x ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
xxx@xxx:~/pytradfri$python -i -m pytradfri 192.168.x.x
DEBUG:pytradfri.api.libcoap_api:Executing 192.168.x.x get ['15001']
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/xxx/xxx/pytradfri/pytradfri/__main__.py", line 76, in <module>
devices_commands = api(gateway.get_devices())
File "/home/xxx/xxx/pytradfri/pytradfri/api/libcoap_api.py", line 128, in request
return self._execute(api_commands, timeout=timeout)
File "/home/xxx/xxx/pytradfri/pytradfri/api/libcoap_api.py", line 103, in _execute
raise RequestTimeout() from None
pytradfri.error.RequestTimeout
~$ pip freeze
aiocoap==0.4.3
Cython==0.29.28
DTLSSocket==0.1.12
pydantic==1.9.0
pytradfri==10.0.0
typing-extensions==4.1.1
~$ aiocoap-client --credentials tradfri_standalone_psk.json coaps://192.168.x.x:5684/15001
Network error: [Errno 111] Connection refused
I got it fixed now. There was something wrong with the DHCP server / IP mapping.
I did the following:
- Released the leased IP of the Ikea Gateway.
- Mapped static IP for the Ikea Gateway (Used mac address)
- Restarted the router.
- Reset Ikea Gateway.
I got it fixed now. There was something wrong with the DHCP server / IP mapping.
I did the following:
- Released the leased IP of the Ikea Gateway.
- Mapped static IP for the Ikea Gateway (Used mac address)
- Restarted the router.
- Reset Ikea Gateway.
This is interesting... I've recently started monitoring my Tradfri gateway every minute... and it runs for a couple hours and then fails. It fails when getting the device endpoints or when getting the device data. There are 10 devices.
I have a static IP set for the gateway but the lease time is a couple hours at most. max-lease-time 7200
.
In my gateway: firmware_version='1.19.32'
I guess it is time to start looking at the failures, power cycling and dhcpd logs to see if there is a correlation.