script produces error [Solved]
Posted: Friday 01 May 2020 12:13
I switched from Raspi to Windows. The scripts were fine under Buster
Here is the script
producing the error:
Here is the script
Code: Select all
-- assumptions:
-- the setpoint is set by a selector dummy device where the values are numeric temperatures
-- but you can easily change it to a setpoint device
local BOILER_DEVICE = 'FB 23 Heizkreis Buero' -- switch device
local SETPOINT_DEVICE = 'Solltemperatur Buero' -- selector dummy device
local TEMPERATURE_SENSOR = 'Buero'
local MODUS_DEVICE = 'Modus Waermepumpe' -- selector dummy device
local LOGGING = false
return
{
on =
{
timer =
{
'every 3 minutes'
},
},
logging =
{
level = LOGGING and domoticz.LOG_DEBUG or domoticz.LOG_ERROR or domoticz.LOG_INFO,
marker = 'HZ Buero',
},
active = true,
execute = function(domoticz)
local boiler = domoticz.devices(BOILER_DEVICE)
local temperature = domoticz.devices(TEMPERATURE_SENSOR).temperature
local setpoint = domoticz.devices(SETPOINT_DEVICE).levelName
local modusState = domoticz.devices(MODUS_DEVICE).state
local boilerState = boiler.state
local setpointValue = tonumber(setpoint)
domoticz.log('Current temperature: ' .. temperature, domoticz.LOG_DEBUG)
domoticz.log('Setpoint: ' .. setpointValue, domoticz.LOG_DEBUG)
domoticz.log('Current boiler state: ' .. boilerState, domoticz.LOG_DEBUG)
-- now determine what to do
if setpoint == 'Off' or modusState ~= 'Heizen' then
boiler.switchOff()
elseif temperature > setpointValue and boilerState == 'On' then
boiler.switchOff()
elseif temperature <= setpointValue and boilerState == 'Off' and modusState == 'Heizen' then
boiler.switchOn()
end
if temperature > setpointValue then
domoticz.log('Target temperature reached, boiler off', domoticz.LOG_INFO)
else
domoticz.log('Target temperature not reached, boiler on', domoticz.LOG_INFO)
end
end
}
Code: Select all
2020-05-01 12:09:00.400 Error: dzVents: Error: (3.0.2) HZ Buero: An error occurred when calling event handler Klima Buero
2020-05-01 12:09:00.400 Error: dzVents: Error: (3.0.2) HZ Buero: ...oticz\scripts\dzVents\generated_scripts/Klima Buero.lua:39: attempt to concatenate a nil value (local 'setpointValue')