I recently "borrowed" a script for heating up my so called "blokhut", meant to fire up a heating device, when the temp becomes below setpoint...
The script which I have borrowed and adapted is:
- Spoiler: show
-
-- assumptions:
-- the setpoint is set by a dummy device (not a selector type)
local CV_SWITCH = 'Sonoff Terras' -- switch device
local TEMP_SETPOINT = 'Thermostaat_Blokhut' -- selector dummy device
local TEMP_SENSOR_1 = 'Temp Blokhut'
local BAT_THRESHOLD = 30
local LOGGING = true
return
{
on =
{
timer =
{
'every 10 minutes',
},
devices =
{
CV_SWITCH,
},
},
--LOG levell: This is the log level you want for this script. Can be domoticz.LOG_INFO, domoticz.LOG_MODULE_EXEC_INFO, domoticz.LOG_DEBUG or domoticz.LOG_ERROR
--marker: A string that is prefixed before each log message. That way you can easily create a filter in the Domoticz log to see just these messages.
logging =
{
level = LOGGING and domoticz.LOG_DEBUG or domoticz.LOG_ERROR,
--level = LOGGING and domoticz.LOG_ERROR,
marker = 'dzVents heating',
},
execute = function(dz)
-- collect all input data
local boiler_switch_state = dz.devices(CV_SWITCH).state
local temp_1 = dz.devices(TEMP_SENSOR_1).temperature
local setpointValue = dz.devices(TEMP_SETPOINT).setPoint
-- info only on log level = LOG_DEBUG
dz.log('CV_SWITCH : ' .. boiler_switch_state, dz.LOG_DEBUG)
dz.log('Temp_1 : ' .. temp_1, dz.LOG_DEBUG)
dz.log('Setpoint_value : ' .. setpointValue, dz.LOG_DEBUG)
-- now determine what to do
if (temp_1 >= setpointValue) then
dz.devices(CV_SWITCH).switchOff()
dz.log('Target temperature reached, boiler off')
elseif (temp_1 <= (setpointValue -1)) then
dz.log('Average temperature more than 1 degree below setpointValue, switchOn during 10 minutes')
dz.devices(CV_SWITCH).switchOn().forMin(2)
elseif (temp_1 > (setpointValue -1)) then
dz.log('Average temperature less than 1 degree below setpointValue, switchOn during 5 minutes')
dz.devices(CV_SWITCH).switchOn().forMin(1)
end
end
}
- Spoiler: show
-
2020-11-24 06:36:19.929 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-11-24 06:36:20.764 (Dummy) Light/Switch (Sonoff Terras)
2020-11-24 06:36:20.670 Status: dzVents: Info: Handling events for: "Sonoff Terras", value: "Off"
2020-11-24 06:36:20.671 Status: dzVents: Info: dzVents heating: ------ Start internal script: Verwarming Blokhut: Device: "Sonoff Terras (Dummy)", Index: 48
2020-11-24 06:36:20.678 Status: dzVents: Debug: dzVents heating: Processing device-adapter for Temp Blokhut: Temperature+humidity device adapter
2020-11-24 06:36:20.686 Status: dzVents: Debug: dzVents heating: Processing device-adapter for Thermostaat_Blokhut: Thermostat setpoint device adapter
2020-11-24 06:36:20.687 Status: dzVents: Debug: dzVents heating: CV_SWITCH : Off
2020-11-24 06:36:20.687 Status: dzVents: Debug: dzVents heating: Temp_1 : 5.6999998092651
2020-11-24 06:36:20.687 Status: dzVents: Debug: dzVents heating: Setpoint_value : 3.5
2020-11-24 06:36:20.688 Status: dzVents: Debug: dzVents heating: Constructed timed-command: Off
2020-11-24 06:36:20.689 Status: dzVents: Info: dzVents heating: Target temperature reached, boiler off
2020-11-24 06:36:20.689 Status: dzVents: Info: dzVents heating: ------ Finished Verwarming Blokhut

Unfortunatly the script is turning bonkers on my log.
- Spoiler: show
- 2020-11-24 06:36:19.929 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-11-24 06:36:20.764 (Dummy) Light/Switch (Sonoff Terras)
2020-11-24 06:36:20.670 Status: dzVents: Info: Handling events for: "Sonoff Terras", value: "Off"
2020-11-24 06:36:20.671 Status: dzVents: Info: dzVents heating: ------ Start internal script: Verwarming Blokhut: Device: "Sonoff Terras (Dummy)", Index: 48
2020-11-24 06:36:20.678 Status: dzVents: Debug: dzVents heating: Processing device-adapter for Temp Blokhut: Temperature+humidity device adapter
2020-11-24 06:36:20.686 Status: dzVents: Debug: dzVents heating: Processing device-adapter for Thermostaat_Blokhut: Thermostat setpoint device adapter
2020-11-24 06:36:20.687 Status: dzVents: Debug: dzVents heating: CV_SWITCH : Off
2020-11-24 06:36:20.687 Status: dzVents: Debug: dzVents heating: Temp_1 : 5.6999998092651
2020-11-24 06:36:20.687 Status: dzVents: Debug: dzVents heating: Setpoint_value : 3.5
2020-11-24 06:36:20.688 Status: dzVents: Debug: dzVents heating: Constructed timed-command: Off
2020-11-24 06:36:20.689 Status: dzVents: Info: dzVents heating: Target temperature reached, boiler off
2020-11-24 06:36:20.689 Status: dzVents: Info: dzVents heating: ------ Finished Verwarming Blokhut
2020-11-24 06:36:20.696 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-11-24 06:36:21.534 (Dummy) Light/Switch (Sonoff Terras)
2020-11-24 06:36:21.431 Status: dzVents: Info: Handling events for: "Sonoff Terras", value: "Off"
2020-11-24 06:36:21.432 Status: dzVents: Info: dzVents heating: ------ Start internal script: Verwarming Blokhut: Device: "Sonoff Terras (Dummy)", Index: 48
2020-11-24 06:36:21.439 Status: dzVents: Debug: dzVents heating: Processing device-adapter for Temp Blokhut: Temperature+humidity device adapter
2020-11-24 06:36:21.447 Status: dzVents: Debug: dzVents heating: Processing device-adapter for Thermostaat_Blokhut: Thermostat setpoint device adapter
2020-11-24 06:36:21.447 Status: dzVents: Debug: dzVents heating: CV_SWITCH : Off
2020-11-24 06:36:21.447 Status: dzVents: Debug: dzVents heating: Temp_1 : 5.6999998092651
2020-11-24 06:36:21.448 Status: dzVents: Debug: dzVents heating: Setpoint_value : 3.5
2020-11-24 06:36:21.448 Status: dzVents: Debug: dzVents heating: Constructed timed-command: Off
2020-11-24 06:36:21.449 Status: dzVents: Info: dzVents heating: Target temperature reached, boiler off
2020-11-24 06:36:21.449 Status: dzVents: Info: dzVents heating: ------ Finished Verwarming Blokhut
2020-11-24 06:36:21.457 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-11-24 06:36:22.267 (Dummy) Light/Switch (Sonoff Terras)
2020-11-24 06:36:22.159 Status: dzVents: Info: Handling events for: "Sonoff Terras", value: "Off"
2020-11-24 06:36:22.160 Status: dzVents: Info: dzVents heating: ------ Start internal script: Verwarming Blokhut: Device: "Sonoff Terras (Dummy)", Index: 48
2020-11-24 06:36:22.168 Status: dzVents: Debug: dzVents heating: Processing device-adapter for Temp Blokhut: Temperature+humidity device adapter
2020-11-24 06:36:22.176 Status: dzVents: Debug: dzVents heating: Processing device-adapter for Thermostaat_Blokhut: Thermostat setpoint device adapter
2020-11-24 06:36:22.176 Status: dzVents: Debug: dzVents heating: CV_SWITCH : Off
2020-11-24 06:36:22.177 Status: dzVents: Debug: dzVents heating: Temp_1 : 5.6999998092651
2020-11-24 06:36:22.177 Status: dzVents: Debug: dzVents heating: Setpoint_value : 3.5
2020-11-24 06:36:22.178 Status: dzVents: Debug: dzVents heating: Constructed timed-command: Off
2020-11-24 06:36:22.178 Status: dzVents: Info: dzVents heating: Target temperature reached, boiler off
2020-11-24 06:36:22.179 Status: dzVents: Info: dzVents heating: ------ Finished Verwarming Blokhut
2020-11-24 06:36:22.186 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-11-24 06:36:22.909 Status: dzVents: Info: Handling events for: "Sonoff Terras", value: "Off"
2020-11-24 06:36:22.910 Status: dzVents: Info: dzVents heating: ------ Start internal script: Verwarming Blokhut: Device: "Sonoff Terras (Dummy)", Index: 48
2020-11-24 06:36:22.918 Status: dzVents: Debug: dzVents heating: Processing device-adapter for Temp Blokhut: Temperature+humidity device adapter
2020-11-24 06:36:22.927 Status: dzVents: Debug: dzVents heating: Processing device-adapter for Thermostaat_Blokhut: Thermostat setpoint device adapter
2020-11-24 06:36:22.928 Status: dzVents: Debug: dzVents heating: CV_SWITCH : Off
2020-11-24 06:36:22.928 Status: dzVents: Debug: dzVents heating: Temp_1 : 5.6999998092651
2020-11-24 06:36:22.929 Status: dzVents: Debug: dzVents heating: Setpoint_value : 3.5
2020-11-24 06:36:22.929 Status: dzVents: Debug: dzVents heating: Constructed timed-command: Off
2020-11-24 06:36:22.930 Status: dzVents: Info: dzVents heating: Target temperature reached, boiler off
2020-11-24 06:36:22.931 Status: dzVents: Info: dzVents heating: ------ Finished Verwarming Blokhut
2020-11-24 06:36:22.938 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-11-24 06:36:23.003 (Dummy) Light/Switch (Sonoff Terras)
and so on....
Is ther e a possibility to create an end flag in the script to make the script run once every 10 minutes?
thank you in advance...