bug updating text sensor when empty? (SOLVED)

Python and python framework

Moderator: leecollings

Post Reply
willemd
Posts: 650
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

bug updating text sensor when empty? (SOLVED)

Post 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.
Last edited by willemd on Thursday 12 January 2023 8:47, edited 1 time in total.
User avatar
jvdz
Posts: 2330
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: bug updating text sensor when empty?

Post by jvdz »

Which JSON call do you do to clear the text sensor?
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
willemd
Posts: 650
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: bug updating text sensor when empty?

Post 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
willemd
Posts: 650
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: bug updating text sensor when empty?

Post 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.
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

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

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: mvveelen and 1 guest