Trying to debug and understand dzVents.
For my knowledge I think the logic is OK but to get a faultless script I kindly ask you for some assistance.
In my code some lines are commented to get the script running without errors in the log.
I was already happy I could achieve this step.
Debugging for me means uncomment a line hit save and watch the log page what happens.
Read the dzVents wiki, google my keyboard to wearing the keys, this is after 1 week where I stranded after try and error.
The goal of the script is easy to ubderstand (for me) logic.
Nothing fancy but WYSIWYG in the code.
I watched other contributions but they are out of league to undetstand the working and that is my second aim.
Code: Select all
-- DIY dzVents script for simple Yet Another Thermostat (YAT) beta 1.04
-- used stuff.............
-- thermostat (dummy switchselector)
-- off (switchselector level 0)
-- auto (switchselector level 10)
-- manual (switchselector level 20)
-- boost (switchselector level 30)
-- room_temperature (dummy switch with tempsensor through ESPEASY) DS18B20
-- setpoint_manual_temp (dummy setpoint switch)
-- setpoint_boost_temp (dummy setpoint switch)
-- heater (dummy switch controling relay ON/OFF through ESPEASY http command)
-- status (dummy textbox to show current status in dashboard)
-- vartemp (variable to carry float temperature value)
return
{
on = {
devices = {'thermostat', 'heater', 'room_temperature', 'status', 'setpoint_manual_temp', 'setpoint_boost_temp'},
timer = {'every minute'},
variables = {'vartemp'},
},
--=======================================================
-- USER VARIABLES // name of user variables in Domoticz (float in this example code) ( Setup > More options > User variables).
--=======================================================
execute = function(dz,device)
-- auto mode active initiated by thermostat switchselector at level 10
if (dz.devices('thermostat').switchSelector(10).nValue == 1) then
if (dz.time.matchesRule('at 00:00-05:00 on mon')) then -- P1 notation = sat,sun,mon,tue,wed,thu,fri
(dz.variables('vartemp') == 17)
((dz.devices('status').updateText == 'Auto mode - Monday P1 00:00-05:00 17 Degrees Celsius')) -- show in textbox
elseif
(dz.time.matchesRule('at 05:00-08:00 on mon')) then -- P2 notation = sat,sun,mon,tue,wed,thu,fri
(dz.variables('vartemp') == 18)
((dz.devices('status').updateText == 'Auto mode - Monday P1 00:00-05:00 17 Degrees Celsius')) -- show in textbox
elseif
(dz.time.matchesRule('at 08:00-12:00 on mon')) then -- P3 notation = sat,sun,mon,tue,wed,thu,fri
(dz.variables('vartemp') == 19)
((dz.devices('status').updateText == 'Auto mode - Monday P1 00:00-05:00 17 Degrees Celsius')) -- show in textbox
elseif
(dz.time.matchesRule('at 12:00-18:00 on mon')) then -- P4 notation = sat,sun,mon,tue,wed,thu,fri
(dz.variables('vartemp') == 20)
((dz.devices('status').updateText == 'Auto mode - Monday P1 00:00-05:00 17 Degrees Celsius')) -- show in textbox
elseif
(dz.time.matchesRule('at 18:00-21:00 on mon')) then -- P5 notation = sat,sun,mon,tue,wed,thu,fri
(dz.variables('vartemp') == 21.6)
((dz.devices('status').updateText == 'Auto mode - Monday P1 00:00-05:00 17 Degrees Celsius')) -- show in textbox
elseif
(dz.time.matchesRule('at 21:00-23:59 on mon')) then -- P6 notation = sat,sun,mon,tue,wed,thu,fri
(dz.variables('vartemp') == 17)
((dz.devices('status').updateText == 'Auto mode - Monday P1 00:00-05:00 17 Degrees Celsius')) -- show in textbox
end
dz.log('Auto mode selected')
-- manual mode active initiated by thermostat switchselector at level 20
elseif (dz.devices('thermostat').switchSelector(20).nValue == 1) then
--(dz.variables('vartemp').value == 'setpoint_manual_temp')
--((dz.devices('status').updateText == 'Manual mode at '..'setpoint_manual_temp'..' Degrees Celsius')) -- show in textbox
dz.log('Manual mode selected')
-- boost mode active initiated by thermostat switchselector at level 30
elseif (dz.devices('thermostat').switchSelector(30)).nvalue == 1 then
--(dz.variables('vartemp').value == 'setpoint_boost_temp')
--((dz.devices('status').updateText == 'Boost mode at'..'setpoint_boost_temp'..' Degrees Celsius')) -- show in textbox
--((dz.devices('thermostat').switchSelector(10).timerswitchOff().afterMin(60))) -- return to auto mode after 60 minutes boost time is elapsed
dz.log('Boost mode selected')
end
-- heater switch with 0.3 degrees Celsius hysteresis
if (dz.devices('thermostat').switchSelector(0)).nvalue ~= 0 then
--if (dz.devices('room_temperature').value) < ((dz.variables('vartemp').value - 0.3)) then
--dz.devices('heater').switchOn()
--else
--dz.devices('heater').switchOff()
--end -- heater switch
else
--((dz.devices('status').updateText == 'System switched OFF')) -- show in textbox
end
end --execute
}
It might there are some basic things going wrong in coding but willing to learn step by step.
My current number one problem is when the script runs as it is now the state of the switchselector in Domoticz can not be selected.
As if the sript is blocking the state selection.
Thanks in advance.
Paco