I have these data:
Code: Select all
{
"ActTime" : 1588718227,
"AstrTwilightEnd" : "23:55",
"AstrTwilightStart" : "03:04",
"CivTwilightEnd" : "21:48",
"CivTwilightStart" : "05:12",
"DayLength" : "15:16",
"NautTwilightEnd" : "22:42",
"NautTwilightStart" : "04:18",
"ServerTime" : "2020-05-06 00:37:07",
"SunAtSouth" : "13:30",
"Sunrise" : "05:52",
"Sunset" : "21:08",
"app_version" : "2020.2",
"result" :
[
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 255,
"CustomImage" : 0,
"Data" : "16.0",
"Description" : "",
"Favorite" : 1,
"HardwareID" : 4,
"HardwareName" : "Dummy",
"HardwareType" : "Dummy (Does nothing, use for virtual switches only)",
"HardwareTypeVal" : 15,
"HaveTimeout" : false,
"ID" : "001405F",
"LastUpdate" : "2020-05-06 00:30:01",
"Name" : "Thermostaat_setpoint",
"Notifications" : "false",
"PlanID" : "0",
"PlanIDs" :
[
0
],
"Protected" : false,
"SetPoint" : "16.0",
"ShowNotifications" : true,
"SignalLevel" : "-",
"SubType" : "SetPoint",
"Timers" : "true",
"Type" : "Thermostat",
"TypeImg" : "override_mini",
"Unit" : 1,
"Used" : 1,
"XOffset" : "0",
"YOffset" : "0",
"idx" : "15"
}
],
"status" : "OK",
"title" : "Devices"
}Code: Select all
-- assumptions:
-- the setpoint is set by a dummy device (not a selector type)
local CV_SWITCH = 'CV_switch_auto' -- switch device
local TEMP_SETPOINT = 'Thermostaat_setpoint' -- selector dummy device
local TEMP_SENSOR = 'Oregon'
local LOGGING = true
return
{
on =
{
timer =
{
'every minute'
},
},
logging =
{
level = LOGGING and domoticz.LOG_DEBUG or domoticz.LOG_ERROR,
},
execute = function(dz)
local boiler_switch_state = dz.devices(CV_SWITCH).state
local temperatuur = dz.devices(TEMP_SENSOR).temperature
local temp_gewenst = dz.devices(TEMP_SETPOINT).SetPoint
local setpointValue = tonumber(temp_gewenst)
dz.log('CV_SWITCH: ' .. boiler_switch_state, dz.LOG_DEBUG)
dz.log('Temperatuur: ' .. temperatuur, dz.LOG_DEBUG)
dz.log('Temperature: ' .. temp_gewenst, dz.LOG_DEBUG)
dz.log('Setpoint_value (int): ' .. setpointValue, dz.LOG_DEBUG)
end
}Code: Select all
2020-05-06 00:45:00.333 Status: dzVents: Debug: CV_SWITCH: Off
2020-05-06 00:45:00.333 Status: dzVents: Debug: Temperatuur: 20.700000762939
2020-05-06 00:45:00.333 Status: dzVents: Info: ------ Finished CV
2020-05-06 00:45:00.333 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler CV
2020-05-06 00:45:00.333 Error: dzVents: Error: (3.0.2) ...e/hein/domoticz/scripts/dzVents/generated_scripts/CV.lua:33: attempt to concatenate a nil value (local 'temp_gewenst')