question about dzvents / myscript
Posted: Monday 11 January 2021 17:55
Hi i have a question about dzvents / myscript.
This is THE script that manage all my events, so very important (and it works more then perfect).
And now my situation, in the corona-period, some events are outdated.
for example when a event like "local timer_opstaan_on1" is not active for a certain time i like to disable it.
What is the best way to do this in my script,
by disabling with the local timer with -- signs or something else ?
I can imagine that when adding -- to a timer, the on statement has problems with an non-existent timer...
This is THE script that manage all my events, so very important (and it works more then perfect).
And now my situation, in the corona-period, some events are outdated.
for example when a event like "local timer_opstaan_on1" is not active for a certain time i like to disable it.
What is the best way to do this in my script,
by disabling with the local timer with -- signs or something else ?
I can imagine that when adding -- to a timer, the on statement has problems with an non-existent timer...
Code: Select all
-- dit script bevat de timers voor de Schakelgroepen
-- motion aan uit in verschillende scripts...nakijken .
-- motion 10 seconds timeout omdat nas niet beschikbaar is?
--------------------------------------------------------------------------------------------------------------------------------------------------
local timer_avond_huis_on = '25 minutes before sunset on mon,tue,wed,thu,fri,sat,sun' -- AVOND HUIS SFEERVERLICHTING AAN hele week
local timer_avond_tuin_on = '15 minutes after sunset on mon,tue,wed,thu,fri,sat,sun' -- AVOND TUIN SFEERVERLICHTING AAN hele week
local timer_avond_huis_off1 = 'at 23:00 on mon,tue,wed,thu,sun' -- AVOND SFEERVERLICHTING UIT werkw
local timer_avond_huis_off2 = 'at 23:45 on fri,sat' -- AVOND SFEERVERLICHTING UIT weekend
--------------------------------------------------------------------------------------------------------------------------------------------------
local timer_slapen_on1 = 'at 23:05 on mon,tue,wed,thu,sun' -- SLAPEN AAN werkw
local timer_slapen_on2 = 'at 23:50 on fri,sat' -- SLAPEN AAN weekend
local timer_check = 'at 24:00 on mon,tue,wed,thu,fri,sat,sun' -- CHECKS UITVOEREN
local timer_slapen_off1 = 'at 06:08 on mon,tue,thu,fri' -- SLAPEN UIT werkw peter
local timer_slapen_off2 = 'at 07:08 on mon,tue,wed,thu,fri' -- SLAPEN UIT werkw MO
local timer_slapen_off3 = 'at 08:55 on sat,sun' -- SLAPEN UIT weekend
--------------------------------------------------------------------------------------------------------------------------------------------------
--local timer_opstaan_on1 = 'at 06:10 on mon,tue,thu,fri' -- OPSTAAN AAN werkw peter
local timer_opstaan_on2 = 'at 07:10 on mon,tue,wed,thu,fri' -- OPSTAAN AAN werkw mo
local timer_opstaan_on3 = 'at 09:00 on sat,sun' -- OPSTAAN AAN weekend
--local timer_opstaan_off1 = 'at 06:15 on mon,tue,thu,fri' -- OPSTAAN EINDE werkw peter
local timer_opstaan_off2 = 'at 07:25 on mon,tue,wed,thu,fri' -- OPSTAAN EINDE werkw mo
local timer_opstaan_off3 = 'at 09:15 on sat,sun' -- OPSTAAN EINDE weekend
--------------------------------------------------------------------------------------------------------------------------------------------------
local timer_zon_on = '2 minutes after sunrise on mon,tue,wed,thu,fri,sat,sun' -- ZON OP
local timer_zon_off = '2 minutes after sunset on mon,tue,wed,thu,fri,sat,sun' -- ZON ONDER
--------------------------------------------------------------------------------------------------------------------------------------------------
local timer_ontbijten_on1 = 'at 06:13 on mon,tue,thu,fri' -- ONTBIJTEN AAN werkw PETER
local timer_ontbijten_on2 = 'at 07:20 on mon,tue,wed,thu,fri' -- ONTBIJTEN AAN werkw MO
local timer_ontbijten_on3 = 'at 09:20 on sat,sun' -- ONTBIJTEN AAN WEEKEND
local timer_ontbijten_off1 = 'at 06:44 on mon,tue,thu,fri' -- ONTBIJTEN UIT werkw PETER
local timer_ontbijten_off2 = 'at 08:00 on mon,tue,wed,thu,fri' -- ONTBIJTEN UIT werkw MO
local timer_ontbijten_off3 = 'at 11:00 on sat,sun' -- ONTBIJTEN UIT WEEKEND
--------------------------------------------------------------------------------------------------------------------------------------------------
local timer_rolluik_omhoog1 = 'at 09:00 on mon,tue,wed,thu,fri' -- ZONWERING OMHOOG werkweek NIELS (geen vakantie)
local timer_rolluik_omhoog2 = 'at 11:00 on mon,tue,wed,thu,fri' -- ZONWERING OMHOOG werkweek NIELS (vakantie)
local timer_rolluik_omhoog3 = 'at 11:00 on sat,sun' -- ZONWERING OMHOOG weekend NIELS (geen vakantie)
local timer_rolluik_omlaag1 = 'at 13:00 on mon,tue,wed,thu,fri,sat,sun' -- ZONWERING OMLAAG iedere dag NIELS deze niet als t buiten koud is
local timer_rolluik_omlaag2 = 'at sunset on mon,tue,wed,thu,fri,sat,sun' -- ZONWERING OMLAAG iedere dag NIELS
--------------------------------------------------------------------------------------------------------------------------------------------------
local Timer_dellog = 'at 10:00 on mon,wed,fri,sun' -- SCHONEN VAN DE LOGFILE
return {
on = { timer = {timer_avond_huis_on, timer_avond_tuin_on, timer_slapen_on1, timer_slapen_on2, timer_check, timer_opstaan_on1, timer_opstaan_on2, timer_opstaan_on3, timer_zon_on, timer_ontbijten_on1, timer_ontbijten_on2, timer_ontbijten_on3,
timer_rolluik_omhoog1,timer_rolluik_omhoog2,timer_rolluik_omhoog3,timer_avond_huis_off1, timer_avond_huis_off2, timer_slapen_off1, timer_slapen_off2, timer_slapen_off3, timer_opstaan_off1, timer_opstaan_off2, timer_opstaan_off3, timer_zon_off, timer_ontbijten_off1,
timer_ontbijten_off2, timer_ontbijten_off3,timer_rolluik_omlaag1,timer_rolluik_omlaag2,Timer_dellog,}
},
logging = {
level = domoticz.LOG_ERROR,
},
execute = function(dz,item,info)
_G.logMarker = _G.moduleLabel -- marker wordt scriptnaam, _G.logMarker = info.scriptName is idem
local messageTable = {}
-- HIER START DE EXECUTIE
if (dz.devices('Schakelklok').state == 'uit') then -- GEEN SCHAKELINGEN
dz.helpers.globalMessage2(dz,item,info,messageTable,'add', ' SCHAKELKLOK: staat UIT, er worden geen automatische schakelingen uitgevoerd...')
elseif (dz.devices('Schakelklok').state ~= 'uit') then -- WEL autom timer SCHAKELINGEN
if (item.trigger == timer_avond_huis_on) then -- AVOND HUIS AAN: HUIS sfeerverlichting binnen
dz.devices('Avond').switchSelector('huis')
elseif (item.trigger == timer_avond_tuin_on) then -- AVOND TUIN AAN: TUIN sfeerverlichting buiten
dz.devices('Avond').switchSelector('tuin')
elseif (item.trigger == timer_slapen_off1 or item.trigger == timer_slapen_off2 or item.trigger == timer_slapen_off3) then -- SLAPEN UIT
dz.devices('Slapen').switchOff()
elseif (item.trigger == timer_opstaan_off1 or item.trigger == timer_opstaan_off2 or item.trigger == timer_opstaan_off3) then -- OPSTAAN UIT
dz.devices('Opstaan').switchOff()
elseif (item.trigger == timer_ontbijten_off1 or item.trigger == timer_ontbijten_off2 or item.trigger == timer_ontbijten_off3) then -- ONTBIJTEN UIT
dz.devices('Ontbijten').switchOff()
elseif (item.trigger == timer_zon_on) then -- ZON OP
dz.devices('Zon op').switchOn()
elseif (item.trigger == timer_zon_off) then -- ZON ONDER
dz.devices('Zon op').switchOff()
elseif (item.trigger == Timer_dellog) then -- CLEAN LOG
dz.devices('clear_log').switchOn()
elseif (item.trigger == timer_check) then -- CHECK STUFF
if dz.time.isNightTime then
if (dz.devices('Zon op').state == 'On') then
dz.devices('Zon op').switchOff()
dz.helpers.globalMessage2(dz,item,info,messageTable,'add', ' SCHAKELKLOK: CHECK, status ZON OP klopt niet: is aangepast!...')
end
else -- daytime
if (dz.devices('Zon op').state == 'Off') then
dz.devices('Zon op').switchOn()
dz.helpers.globalMessage2(dz,item,info,messageTable,'add', ' SCHAKELKLOK: CHECK, status ZON OP klopt niet: is aangepast!...')
end
end
elseif (item.trigger == timer_rolluik_omhoog1 or item.trigger == timer_rolluik_omhoog2 or item.trigger == timer_rolluik_omhoog3) then -- ZONWERING OMHOOG
if (item.trigger == timer_rolluik_omhoog1 and dz.devices('Schakelklok').state ~= 'vakantie') then
dz.devices('Niels rolluik').switchOff()
elseif (item.trigger == timer_rolluik_omhoog2 and dz.devices('Schakelklok').state == 'vakantie') then
dz.devices('Niels rolluik').switchOff()
elseif (item.trigger == timer_rolluik_omhoog3) then
dz.devices('Niels rolluik').switchOff()
end
elseif (item.trigger == timer_rolluik_omlaag1) then
grenstmp_zonwering = 18 -- als het boven deze temp is mag t rolluik in de middag omlaag om hitte te voorkomen
huidigtmp = dz.devices('Strijp_temp').temperature
if huidigtmp > grenstmp_zonwering then
dz.devices('Niels rolluik').switchOn()
end
elseif (item.trigger == timer_rolluik_omlaag2) then
dz.devices('Niels rolluik').switchOn()
end
if (dz.devices('Schakelklok').state == 'visite') then -- VISITE
dz.helpers.globalMessage2(dz,item,info,messageTable,'add', ' SCHAKELKLOK: staat op VISITE, er worden beperkt automatische schakelingen uitgevoerd...')
else -- ALS ER GEEN VISITE IS DAN GEWOON AVONDVERLICHTING UIT EN SLAPEN AAN
dz.helpers.globalMessage2(dz,item,info,messageTable,'add', ' SCHAKELKLOK: staat op AUTOMATISCH, er worden automatische schakelingen uitgevoerd...')
if (item.trigger == timer_avond_huis_off1 or item.trigger == timer_avond_huis_off2) then -- AVOND UIT:
dz.devices('Avond').switchSelector('uit')
elseif (item.trigger == timer_slapen_on1 or item.trigger == timer_slapen_on2) then -- SLAPEN AAN
dz.devices('Slapen').switchOn()
end
end
if (dz.devices('Thuis').state == 'On') then -- HUIS VAN ALARM AF, ER IS IEMAND THUIS
if (item.trigger == timer_opstaan_on1 or item.trigger == timer_opstaan_on2 or item.trigger == timer_opstaan_on3) then -- OPSTAAN AAN en GEEN VAKANTIE
dz.devices('Opstaan').switchOn()
elseif (item.trigger == timer_ontbijten_on1 or item.trigger == timer_ontbijten_on2 or item.trigger == timer_ontbijten_on3) then -- ONTBIJTEN AAN als iemand thuis en zon onder ....
if dz.devices('Zon op').state == 'Off' and (dz.devices('Schakelklok').state ~= 'vakantie') then -- zon is nog niet op en geen vakantie ! -- CHECK ZON OP/ONDER
dz.devices('Ontbijten').switchOn()
else
--globalMessage(add, ' ONTBIJTEN wordt niet uitgevoerd, de zon is op ....',logcode)
dz.helpers.globalMessage2(dz,item,info,messageTable,'add', ' ONTBIJTEN wordt niet uitgevoerd, de zon is op of vakantie staat aan....')
end
end
else -- HUIS OP ALARM, ER IS NIEMAND THUIS
dz.helpers.globalMessage2(dz,item,info,messageTable,'add', ' OPSTAAN en ONTBIJTEN scripts worden niet uitgevoerd, er is niemand...')
end
else -- ONBEKENDE WAARDE
dz.helpers.globalMessage2(dz,item,info,messageTable,'add', ' SCHAKELKLOK: heeft een onbekende waarde ...')
end
dz.helpers.globalMessage2(dz,item,info,messageTable,'chg')
end
}