Page 1 of 1

bug updating text sensor when empty? (SOLVED)

Posted: Wednesday 11 January 2023 22:56
by willemd
1) I created a new text sensor.

2) Then I created a small test program to insert a text on the sensor calling the json command (ip replaced by xxx)

Code: Select all

http://xxx.xxx.xxx.xxx:8080/json.htm?type=command&param=udevice&idx=111&nvalue=0&svalue="new text"
THIS WORKED FINE so the program is o.k.

3) I then called a JSON command to clear the sensor, also this works fine.

But if I then repeat step 2 if fails. The text does NOT re-appear. (also not after browser clearing, I did inspect the dbase table as well)

But when I call the same JSON command from a brower the text does re-appear.
And when I then call the python program again it also re-appears.
Or when I first delete and recreate the sensor it also works fine.

So only when the sensor is empty and the json is then triggered from within the python program it fails.

Is this a bug? Why does it work from the browser but not from the program? It is the same JSON command.

Response code from all commands are OK.

Re: bug updating text sensor when empty?

Posted: Wednesday 11 January 2023 23:10
by jvdz
Which JSON call do you do to clear the text sensor?

Re: bug updating text sensor when empty?

Posted: Thursday 12 January 2023 8:34
by willemd
jvdz wrote: Wednesday 11 January 2023 23:10 Which JSON call do you do to clear the text sensor?

Code: Select all

/json.htm?type=command&param=clearlightlog&idx=<idx>
as listed on this page https://www.domoticz.com/wiki/Domoticz_ ... xt_devices

Re: bug updating text sensor when empty?

Posted: Thursday 12 January 2023 8:47
by willemd
I think I found the reason.

When I clear the log, apparently this clear the entries from the lightinglog table but it does not update devicestatus as displayed on the icon. The old text is still there.

When I then try to add the old text, it is the same as in devicestatus and no further action is taken. No insert in the lightinglog.
If I try a different text then it works fine.

When I try the same old text with the browser, the user is different from the one that inserted the old text, so it creates a new entry.

This analysis is confirmed by 1) updating with the browser, 2) then deleting the entries and then 3) using the browser again to insert the same old text. Also in this case no new entry is created, since all data provided as result of the JSON is the same as in devicestatus already.

Re: bug updating text sensor when empty? (SOLVED)

Posted: Thursday 12 January 2023 12:40
by waltervl
It is also named clearlog and not cleardevicevalue ;) so it makes sense it does not update the value.
Perhaps send a space or --- to indicate empty text value.