LUA Setpoint temperature to Temperature conversion

Moderator: leecollings

Post Reply
Bart1992
Posts: 2
Joined: Monday 01 October 2018 21:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

LUA Setpoint temperature to Temperature conversion

Post by Bart1992 »

Hello,

I'm new to Domoticz, and also LUA. What i'm trying is overlaying multiple temperature (sensors) data in a single graph, including the setpoint temp of my Toon thermostat.

I tried building a (what should be) really easy script including the dummy sensor described in multiple topics. I tried to follow the Weatherunderground temperature scraping example, and modified it slightly in which I thought it should work.... however it doens't.

Can somebody please advice me/looking at this script? As can be seen in the attachment it is printing the input ( Room Setpoint --> sWeathertemp ), however it does not update the dummy temp sensor Setpoint ( idx 18 ).

Looking at the script it's also repeating once triggered, how can I stop it after 1 cycle?

( For me it would be easier if this would have been possible in blockly )

Code: Select all

  local sensorwu = 'Room Setpoint' --sensor from wunderground
local idx = 1 --idx of your virtual temp sensor of wunderground

commandArray = {}
 
if devicechanged[sensorwu] then
	sWeatherTemp = otherdevices_svalues[sensorwu]:match("([^;]+)")
	sWeatherTemp = tonumber(sWeatherTemp)
	commandArray['UpdateDevice'] = idx .. '|18|' .. tostring(sWeatherTemp)
	print(sWeatherTemp)
	print(sens_temp)
	
end
return commandArray   
Attachments
Setpoint_Temp.png
Setpoint_Temp.png (19.55 KiB) Viewed 1508 times
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: LUA Setpoint temperature to Temperature conversion

Post by waaren »

Bart1992 wrote: Monday 01 October 2018 22:09 ...What i'm trying is overlaying multiple temperature (sensors) data in a single graph, including the setpoint temp of my Toon thermostat.
Looking at the script it's also repeating once triggered, how can I stop it after 1 cycle?
...
The code is probably saved as a "Device" or "All" triggered Lua script. In that case it is triggered on every device change in the system and every minute.
In this case it makes more sense to save it as a Time triggered script.

Code: Select all

commandArray = {}

    local sensorwu                          = 'Room Setpoint'    -- Toon device 
    local temperatureFromSetpointDeviceIDX  = 1                 -- idx of your virtual temp sensor that will receive setpoint from sensorwu
    local sensorwuTemperature, sensorwuSetpoint, sensorwuMode = otherdevices_svalues[sensorwu]:match("([^;]+);([^;]+);([^;]+)") -- get temp, setpoint and mode from svalues
    commandArray['UpdateDevice'] = temperatureFromSetpointDeviceIDX .. '|0|' .. sensorwuSetpoint                             -- update virtual device
	-- print("Setpoint of " .. sensorwu .. " is: " .. sensorwuSetpoint)                         -- for debug purposes only (print to log)
	
return commandArray 
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: LUA Setpoint temperature to Temperature conversion

Post by waaren »

Bart1992 wrote: Monday 01 October 2018 22:09 ...What i'm trying is overlaying multiple temperature (sensors) data in a single graph, including the setpoint temp of my Toon thermostat.
Looking at the script it's also repeating once triggered, how can I stop it after 1 cycle?
...
The previous Lua script was based on my testing on an Evo home temperature + setPoint device.
For a Toon setpoint the script is even more simple

Code: Select all

commandArray = {}

    local sensorwu                          = 'Room Setpoint'    -- Toon device 

    local temperatureFromSetpointDeviceIDX  = 1                 -- idx of your virtual temp sensor that will receive setpoint from sensorwu
    local sensorwuSetpoint = otherdevices_svalues[sensorwu]     -- get setpoint 
    commandArray['UpdateDevice'] = temperatureFromSetpointDeviceIDX .. '|0|' .. sensorwuSetpoint                             -- update virtual device
	print("Setpoint of " .. sensorwu .. " is: " .. sensorwuSetpoint)                         -- for debug purposes only (print to log)
	
return commandArray   
 
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Bart1992
Posts: 2
Joined: Monday 01 October 2018 21:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: LUA Setpoint temperature to Temperature conversion

Post by Bart1992 »

Thanks! Your last small script did the trick, seems really easy when you know the syntax :) !
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest