Sensor is not updated by Luascript (http poller)

Moderator: leecollings

Post Reply
bhei
Posts: 2
Joined: Monday 05 January 2026 21:51
Target OS: Linux
Domoticz version:
Contact:

Sensor is not updated by Luascript (http poller)

Post by bhei »

Hi,

I just installed Domoticz, and I want to use it to display data which I can read out from a device via JSON.

What I did:
  • Create Dummy Hardware
  • Create Virtual Sensor, Type "Temp", which received the ID 14051
  • Create Hardware "HTTP/HTTPS poller" with custom command file.
  • I created the following lua file based on the example_json.lua file

Code: Select all

-- Retrieve the request content
s = request['content'];

-- Update some devices (index are here for this example)
local temp = domoticz_applyJsonPath(s,'temp')
domoticz_updateDevice(14051,temp,'')
The log file of Domoticz shows proper readout:

Code: Select all

Debug: CLuaHandler (updateDevice from LUA) : idx=14051 nvalue=23.5 svalue= invalue=23 signallevel=12 batterylevel=255
Still the temperature sensor in Domoticz is not updated and stuck at "0°C".
couldn't find any documentation on the domoticz_updateDevice() command and had to try out to find that the second parameter is the nValue and the third one is an sValue.
Does anyone have a clue what I'm doing wrong?

Thank you!
User avatar
waltervl
Posts: 6676
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Sensor is not updated by Luascript

Post by waltervl »

I moved this topic to Lua subforum.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waltervl
Posts: 6676
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Sensor is not updated by Luascript (http poller)

Post by waltervl »

https://wiki.domoticz.com/HTTP/HTTPS_poller

Code: Select all

Special Lua parser functions for Domoticz:

domoticz_updateDevice(deviceId (integer), svalue (string), {nvalue (string) | nvalue (integer)}, [rssi(integer)], [battery(integer)])
It seems in your case you need to put it into a string as the value 23.5 is no integer
Perhaps this works?

Code: Select all

domoticz_updateDevice(14051,".. temp ..")
Or as in the example on the wiki

Code: Select all

domoticz_updateDevice(14051,'',temp)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
bhei
Posts: 2
Joined: Monday 05 January 2026 21:51
Target OS: Linux
Domoticz version:
Contact:

Re: Sensor is not updated by Luascript (http poller)

Post by bhei »

waltervl wrote: Tuesday 06 January 2026 9:57 Or as in the example on the wiki

Code: Select all

domoticz_updateDevice(14051,'',temp)
Actually, this IS correct! I never expected that the sensor expects a number as a string. :lol:

The main issue was that I selected the wrong ID. I checked several pages in the wiki for help, and on https://wiki.domoticz.com/Virtual_meter it says: Note the ID of the sensor, while it should be IDX. So using "1" instead of "14051" makes the whole thing work.

Thanks for the pointer, it works now!

Now on to the next issue: In the diagrams the temperatures are only shown in 5 minute increments. Is there any way to adjust this to for example 1 minute, or 30 seconds?
User avatar
waltervl
Posts: 6676
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Sensor is not updated by Luascript (http poller)

Post by waltervl »

No, it only displays per 5 minutes. It is home automation, normally no need to display values in shorter deltas.

If you want it you need to export the values to for example influxdb and graph them with grafana. There are instructions how to do that on the wiki.
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: No registered users and 1 guest