Closed d1nd141 closed 5 years ago
Hello, the python interface always loads all data of a device, because FHEM offers no other possibility. The data is then filtered by python-fhem. Therefore, from a performance perspective, it is better to filter the readings yourself if you need several readings from one device, like this:
data = fh.get_device_reading("myWeather", ["fc1_day_of_week", "fc1_code"], value_only=True)
temp_1_code = data["temp_1_code"]
temp_1_wday = data["temp_1_wday"]
Your problem is, that the json data coming from FHEM are not well-formed and can not be parsed by python. I assume that this error is in jsonlist2 of FHEM or in telnet transmission. Did you test if the error also occurs with http?
Maybe this could be catched by requesting the data again when a decode error occours @domschl ? Maybe with a parameter that sets how often?
To catch this problem for the moment you could also do something like this:
# Try 5 times to get correct data
for x in range(5):
data = fh.get_device_reading("myWeather", ["fc1_day_of_week", "fc1_code"], value_only=True)
if data:
break
This is most probably caused by a performance-problem with telnet. In telnet, there are no markers that indicate the actual end of a block, so timing has to be used to infer end-of-transmission. [I can reproduce this error, if I set fh.get_device_reading('myWeather', 'fc1_day_of_week', timeout=0.001)
, reading via telnet]
The errors indicate a JSON decode of an incomplete block, so somehow the system doesn't finish the transmission within timeout=0.1
default constraints.
I would try:
timeout=0.5
(experiment with the value):
e.g. fh.get_device_reading('myWeather', 'fc1_day_of_week', timeout=0.5)
FhemEventQueue
. You can set it up with server-side filters to deliver only the values you are interested in, only when Fhem actively sends them.In the end, when using telnet, proper configuration of timeout
is a requirement, which unfortunately cannot be avoided.
Hi again, i tried with http, and everything works fine. Will probably stay on http connect. As i'm reading at least 26 values, i will check with Queue. (to display on a 7.5 e-ink display)
Thanks 4 your help and explications!
@d1nd141, you're welcome, and thanks @Andre0512 for the help and advice.
Hi, If use f.ex. temp_1_wday = fh.get_device_reading("myWeather", "fc1_day_of_week") temp_1_wday = temp_1_wday['day_of_week'] temp_1_wday = temp_1_wday['Value']
or temp_1_code = fh.get_device_reading("myWeather", "fc1_code") temp_1_code = temp_1_code['fc1_code'] temp_1_code = temp_1_code['Value']
to get a specific reading. Unfortunately sometimes (not always, and also not everytime the same device) i get all readings. Not sure if it's FHEM related or python-fhem:
or