after a manual event or a timed event groups of switches are executed and switches for my dayly cycle (sun op, wake up breakf, etc are put to on-off.. works very nice!
i also made my own logging, not for errors and sensor info, only clear results..
With these rules i can log to domoticz and to my own logging...
for each group of devices: msgtxt = 'LAATSTE SCENES gereset ...'
and at the end of my script:
dz.log('Script: ' .. info.scriptName .. ', device: ' .. item.name .. ' ' .. msgtxt, dz.LOG_INFO)
timertekst = dz.time.rawDate .. ' ' .. dz.time.rawTime .. ' : ' .. msgtxt .. '<br>' .. dz.devices('timerlog').text
dz.devices('timerlog').updateText(timertekst)
Question
In the script below there can be executed more then one scenes/groups.. so my msgtxt is overwritten and only the last one is executed in the log
So i need:
- an array for setting msgtxt
- and a construct that reads all defined msgtxt(1-n) (see the end of my script)
Can somebody give a hand? Script is working more than fine! almost finished
Code: Select all
-- dit script draait bij avond slapen, zon op, ontbijten, van huis, thuis en opstaan, uit huis thuis
local OnTimer1 = '15 minutes before sunset on mon,tue,wed,thu,fri,sat,sun' -- HUIS SFEERVERLICHTING AAN
local OnTimer2 = '15 minutes after sunset on mon,tue,wed,thu,fri,sat,sun' -- TUIN SFEERVERLICHTING AAN
local OffTimer1 = 'at 23:00 on mon,tue,wed,thu,sun' -- EINDE AVOND ALLES UIT DOOR DE WEEK
local OffTimer2 = 'at 23:45 on fri,sat' -- EINDE AVOND ALLES UIT IN HET WEEKEND
local OnTimer3 = 'at 23:05 on mon,tue,wed,thu,sun' -- SLAPEN START door de week
local OnTimer4 = 'at 23:50 on fri,sat' -- SLAPEN START in het weekend
local OffTimer3 = 'at 06:08 on mon,tue,thu,fri' -- EINDE SLAPEN peter
local OffTimer4 = 'at 07:08 on mon,tue,wed,thu,fri' -- EINDE SLAPEN MO
local OnTimer5 = 'at 06:10 on mon,tue,thu,fri' -- OPSTAAN peter
local OnTimer6 = 'at 07:10 on mon,tue,wed,thu,fri' -- OPSTAAN mo
local OffTimer5 = 'at 06:15 on mon,tue,thu,fri' -- EINDE OPSTAAN peter
local OffTimer6 = 'at 07:25 on mon,tue,wed,thu,fri' -- EINDE OPSTAAN mo
local OnTimer7 = '2 minutes after sunrise on mon,tue,wed,thu,fri,sat,sun' -- ZON OP
local OffTimer7 = '2 minutes after sunset on mon,tue,wed,thu,fri,sat,sun' -- ZON ONDER
local OnTimer8 = 'at 06:13 on mon,tue,thu,fri' -- ONTBIJTEN AAN PETER
local OnTimer9 = 'at 07:20 on mon,tue,wed,thu,fri' -- ONTBIJTEN AAN MO
local OnTimer10 = 'at 09:20 on sat,sun' -- ONTBIJTEN AAN WEEKEND
local OffTimer8 = 'at 06:44 on mon,tue,thu,fri' -- ONTBIJTEN UIT PETER
local OffTimer9 = 'at 08:00 on mon,tue,wed,thu,fri' -- ONTBIJTEN UIT MO
local OffTimer10 = 'at 11:00 on sat,sun' -- ONTBIJTEN UIT WEEKEND
return {
on = { devices = {'Schakelgroepen','Jablotronenabled'},
timer = {OnTimer1, OnTimer2, OnTimer3, OnTimer4, OnTimer5, OnTimer6, OnTimer7, OnTimer8, OnTimer9, OnTimer10, OffTimer1, OffTimer2, OffTimer3, OffTimer4, OffTimer5, OffTimer6, OffTimer7, OffTimer8, OffTimer9, OffTimer10}
},
logging = { level = domoticz.LOG_DEBUG,
marker = "Timers"},
execute = function(dz,item,info)
if (
(item.isTimer and (item.trigger == OnTimer1)) -- START AVOND HUIS sfeerverlichting binnen
or (item.isDevice and item.name == 'Schakelgroepen' and (item.state == 'Aan' or item.state == 'Sfeerverlichting binnen'))
) then
--if (item.isTimer) then dz.devices('Schakelgroepen').switchSelector(10) end -- weet niet of deze nodig is n keer remarken
dz.devices('Opstaan').switchOff()
dz.devices('Ontbijten').switchOff()
dz.devices('Slapen').switchOff()
dz.devices('Avond').switchOn()
dz.devices('usb lamp').switchSelector(40)
dz.devices('lantaarn').switchOn()
dz.devices('Lamp dressoir links').switchOn()
dz.devices('Lamp dressoir rechts').switchOn()
dz.devices('Lamp tv links').switchOn()
dz.devices('Lamp tv rechts').switchOn()
msgtxt = 'Verlichting huis wordt AAN gezet...'
end
if (
(item.isTimer and (item.trigger == OnTimer2)) -- START AVOND TUIN sfeerverlichting buiten
or (item.isDevice and item.name == 'Schakelgroepen' and (item.state == 'Aan' or item.state == 'Sfeerverlichting tuin'))
) then
--if (item.isTimer) then dz.devices('Schakelgroepen').switchSelector(20) end -- weet niet of deze nodig is
dz.devices('Opstaan').switchOff()
dz.devices('Ontbijten').switchOff()
dz.devices('Slapen').switchOff()
dz.devices('Avond').switchOn()
dz.devices('Achtertuin huis terraslamp').switchOn()
dz.devices('Borderverlichting').switchOn()
dz.devices('Achtertuin schuur bewegingslamp').switchOn()
dz.devices('Voordeurlamp').switchOn()
dz.devices('Buiten_led_kerstlantaarn').switchOn()
msgtxt = 'Verlichting tuin wordt AAN gezet'
end
if (
(item.isTimer and dz.devices('Visite_disable_timers').state == 'Off' and (item.trigger == OffTimer1 or item.trigger == OffTimer2 )) -- EINDE AVOND via timer of handmatig alles uit
or (item.isDevice and item.name == 'Schakelgroepen' and item.state == 'Uit')
) then
--if (item.isTimer) then dz.devices('Schakelgroepen').switchSelector(0) end -- weet niet of deze nodig is
dz.devices('Avond').switchOff()
dz.devices('Achtertuin huis terraslamp').switchOff()
dz.devices('Borderverlichting').switchOff()
dz.devices('Achtertuin schuur bewegingslamp').switchOff()
dz.devices('Voordeurlamp').switchOff()
dz.devices('Buiten_led_kerstlantaarn').switchOff()
dz.devices('usb lamp').switchSelector(0)
dz.devices('lantaarn').switchOff()
dz.devices('Lamp dressoir links').switchOff()
dz.devices('Lamp dressoir rechts').switchOff()
dz.devices('Lamp tv links').switchOff()
dz.devices('Lamp tv rechts').switchOff()
msgtxt = 'ALLE verlichting huis wordt UIT gezet'
end
if (
(item.isTimer and (item.trigger == OnTimer3 or item.trigger == OnTimer4)) -- START SLAPEN
or (item.isDevice and item.name == 'Schakelgroepen' and (item.state == 'Aan' or item.state == 'Slapen'))
) then
--if (item.isTimer) then dz.devices('Schakelgroepen').switchSelector(30) end -- weet niet of deze nodig is
dz.devices('Opstaan').switchOff()
dz.devices('Ontbijten').switchOff()
dz.devices('Avond').switchOff()
dz.devices('Slapen').switchOn()
dz.devices('Achtertuin schuur bewegingslamp').switchOn()
dz.devices('Voordeurlamp').switchOn()
dz.devices('Buiten_led_kerstlantaarn').switchOn()
if item.isTimer and item.trigger == OnTimer3 then
dz.devices('Bewegingsservice').switchOn().checkFirst().afterMin(70)
elseif item.isTimer and item.trigger == OnTimer4 then
dz.devices('Bewegingsservice').switchOn().checkFirst().afterMin(30)
elseif item.isDevice and item.state == 'Slapen' then
dz.devices('Bewegingsservice').switchOn().checkFirst()
end
msgtxt = 'SLAPEN, nachtverlichting en bewegingsservice wordt AAN gezet...'
end
if (
(item.isTimer and (item.trigger == OffTimer3 or item.trigger == OffTimer4)) -- EINDE SLAPEN
or (item.isDevice and item.name == 'Schakelgroepen' and item.state == 'Uit')
) then
dz.devices('Slapen').switchOff()
msgtxt = 'SLAPEN voorbij ...'
end
if (
(item.isTimer and (item.trigger == OnTimer7)) -- ZON OP
or (item.isDevice and item.name == 'Schakelgroepen' and item.state == 'Zon op') -- handmatig Zon op
) then
--if (item.isTimer) then dz.devices('Schakelgroepen').switchSelector(30) end -- niet nodig
dz.devices('Zon op').switchOn()
dz.devices('Zon onder').switchOff()
dz.devices('Achtertuin schuur bewegingslamp').switchOff()
dz.devices('Voordeurlamp').switchOff()
dz.devices('Buiten_led_kerstlantaarn').switchOff()
-- ONTBIJT DEVICES Kunnen al aan staan evt uitzetten !!!
dz.devices('Achtertuin huis terraslamp').switchOff()
dz.devices('Lamp dressoir links').switchOff()
msgtxt = 'ZON OP....'
end
if (
(item.isTimer and (item.trigger == OffTimer7)) -- ZON ONDER
or (item.isDevice and item.name == 'Schakelgroepen' and item.state == 'Zon onder') -- handmatig Zon onder
) then
--if (item.isTimer) then dz.devices('Schakelgroepen').switchSelector(30) end -- niet nodig
dz.devices('Zon op').switchOff()
dz.devices('Zon onder').switchOn()
msgtxt = 'ZON ONDER....'
end
if (
(item.isTimer and (item.trigger == OnTimer5 or item.trigger == OnTimer6)) -- START OPSTAAN
or (item.isDevice and item.name == 'Schakelgroepen' and (item.state == 'Aan' or item.state == 'Opstaan')) -- is nog niet gemaakt
) then
--if (item.isTimer) then dz.devices('Schakelgroepen').switchSelector(40) end -- weet niet of deze nodig is
dz.devices('Opstaan').switchOn()
if dz.devices('Jablotronenabled').state == 'Unlocked' then -- huis is van alarm, er is iemand thuis
dz.devices('Nachtlamp').switchOn()
dz.devices('Bewegingsservice').switchOff().checkFirst()
msgtxt = 'OPSTAAN wordt uitgevoerd, want er is iemand thuis....'
elseif dz.devices('Jablotronenabled').state == 'Locked' then -- huis op alarm, iedereen is weg, dus niets aanzetten
msgtxt = 'OPSTAAN wordt niet uitgevoerd, want er is niemand thuis....'
end
end
if (
(item.isTimer and (item.trigger == OffTimer5 or item.trigger == OffTimer6)) -- EINDE OPSTAAN
or (item.isDevice and item.name == 'Schakelgroepen' and item.state == 'Uit')
) then
--if (item.isTimer) then dz.devices('Schakelgroepen').switchSelector(30) end -- niet nodig er is geen uit knop
dz.devices('Opstaan').switchOff()
dz.devices('Nachtlamp').switchOff()
msgtxt = 'OPSTAAN voorbij....'
end
if (
(item.isDevice and item.name == 'Schakelgroepen' and item.state == 'Uit huis') -- UIT HUIS
or (item.isDevice and item.name == 'Jablotronenabled' and item.state == 'Locked') -- op alarm
) then
dz.devices('Opstaan').switchOff() -- basisvoorziening UIT want er is niemand thuis
dz.devices('Ontbijten').switchOff() -- basisvoorziening UIT want er is niemand thuis
dz.devices('Thuis').switchOff() -- basisvoorziening UIT want er is niemand thuis
dz.devices('Uit huis').switchOn() -- basisvoorziening UIT want er is niemand thuis
dz.devices('Bewegingsservice').switchOn()
msgtxt = 'UIT HUIS, basisvoorzieningen uit, bewegingservice AAN...'
end
if (
(item.isDevice and item.name == 'Schakelgroepen' and item.state == 'Thuis') -- THUIS
or (item.isDevice and item.name == 'Jablotronenabled' and item.state == 'Unlocked') -- van alarm af
) then
dz.devices('Uit huis').switchOff() -- basisvoorziening UIT want er is niemand thuis
dz.devices('Thuis').switchOn() -- basisvoorziening UIT want er is niemand thuis
dz.devices('Bewegingsservice').switchOff()
msgtxt = 'THUIS, basisvoorzieningen aan, bewegingservice UIT...'
end
if (
(item.isTimer and (item.trigger == OnTimer5 or item.trigger == OnTimer6)) -- BASISVOORZIENING AAN bij timer OPSTAAN
or (item.isDevice and item.name == 'Schakelgroepen' and (item.state == 'Basisvoorziening' or item.state == 'Opstaan' or item.state == 'Thuis')) -- AANZETTEN bij handmatig BASISVOORZIENING, OPSTAAN en THUIS
) then
dz.devices('boiler').switchOn()
dz.devices('printer').switchOn()
msgtxt = 'BASISVOORZIENING AAN...'
end
if (
(item.isTimer and (item.trigger == OnTimer1 or item.trigger == OnTimer2)) -- BASISVOORZIENING UIT bij einde avond
or (item.isDevice and item.name == 'Schakelgroepen' and (item.state == 'Uit' or item.state == 'Slapen' or item.state == 'Uit huis')) -- ACTIVEREN bij handmatig Uit, Slapen en Uit huis
) then
dz.devices('boiler').switchOff()
dz.devices('printer').switchOff()
end
if (
(item.isTimer and (item.trigger == OnTimer8 or item.trigger == OnTimer9 or item.trigger == OnTimer10)) -- START ONTBIJTEN
or (item.isDevice and item.name == 'Schakelgroepen' and (item.state == 'Aan' or item.state == 'Ontbijten'))
) then
dz.devices('Ontbijten').switchOn()
if dz.devices('Jablotronenabled').state == 'Unlocked' then -- huis is van alarm, er is iemand thuis
if dz.devices('Zon onder').state == 'On' then -- als de zon nog niet op is
dz.devices('Achtertuin huis terraslamp').switchOn()
dz.devices('Lamp dressoir links').switchOn()
msgtxt = 'ONTBIJTEN wordt uitgevoerd, want er is iemand thuis en het is nog donker...'
else
msgtxt = 'ONTBIJTEN wordt niet uitgevoerd, want de zon is op ....'
end
elseif dz.devices('Jablotronenabled').state == 'Locked' then -- huis op alarm, iedereen is weg, dus niets aanzetten
msgtxt = 'ONTBIJTEN wordt niet uitgevoerd, want er is niemand thuis....'
end
end
if (
(item.isTimer and (item.trigger == OffTimer8 or item.trigger == OffTimer9 or item.trigger == OffTimer10)) -- EINDE ONTBIJTEN
or (item.isDevice and item.name == 'Schakelgroepen' and item.state == 'Uit')
) then
dz.devices('Ontbijten').switchOff()
dz.devices('Achtertuin huis terraslamp').switchOff()
dz.devices('Lamp dressoir links').switchOff()
msgtxt = 'ONTBIJTEN is afgelopen ...'
end
if (
(item.isDevice and item.name == 'Schakelgroepen' and item.state == 'Uit') -- RESET VAN DE LAATSTE SCENES BIJ handmatig UIT, rest is al gereset
) then
if dz.devices('Jablotronenabled').state == 'Unlocked' then -- huis is van alarm, er is iemand thuis
dz.devices('Uit huis').switchOff()
dz.devices('Thuis').switchOn()
else
dz.devices('Uit huis').switchOn()
dz.devices('Thuis').switchOff()
end
if dz.time.isNightTime then -- als de zon nog niet op is
dz.devices('Zon op').switchOff()
dz.devices('Zon onder').switchOn()
else
dz.devices('Zon op').switchOn()
dz.devices('Zon onder').switchOff()
end
msgtxt = 'LAATSTE SCENES gereset ...'
end
dz.log('Script: ' .. info.scriptName .. ', device: ' .. item.name .. ' ' .. msgtxt, dz.LOG_INFO)
timertekst = dz.time.rawDate .. ' ' .. dz.time.rawTime .. ' : ' .. msgtxt .. '<br>' .. dz.devices('timerlog').text
dz.devices('timerlog').updateText(timertekst)
end
}