I'm trying to solve this issue for few weeks now and really need your help and expertise
I'm running Domoticz version:
Version: 2020.2
Build Hash: b63341bc0
Compile Date: 2020-04-26 18:47:55
dzVents Version: 3.0.2
Python Version: 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0]
Some background:
I have a Holiday-switch, a sleep-scene that triggers a sleep-switch and according to those states the script should execute certain things different. This seems to work for all device-triggered events. Then according to e.g. holiday mode the script needs to execute a command with the
Code: Select all
at('10:00 on mon-fri')Also i have a seperate script for daytime hours (defined by myself) and nighttime hours (also defined myself) with the rule:
Code: Select all
(domoticz.time.matchesRule('at 09:00-22:00 on mon-fri')I then programmed a small script to clear all queued commands for all those devices but this also doesn't seem to make any difference.
I reprogrammed the 2 scripts (Day and Night) with seperate if-statements for device and time-triggered events, this does makes sure that the right script executes at the right time, but the timed commands still only execute the first two days
I'm probably doing something wrong or these funtionalties only work with the newer dzVents version (I'm still running the old version, not ready to update to newest stable yet)
Here the Day script (the night-script works in the same way but different times);
Code: Select all
return {
on = {
devices = {'Home',
'Music',
'Holiday',
'Sleep'
},
timer = {'at 9:00-22:00 on mon-fri',
'at 10:00-22:00 on sat-sun'
},
variables = {},
scenes = {},
groups = {},
security = {},
httpResponses = {},
customEvents = {},
system = {},
},
data = {},
logging = {},
execute = function(domoticz, item)
local someone=domoticz.devices('Home') -- some one home
local holiday=domoticz.devices('Holiday') -- holiday
local sleep=domoticz.devices('Sleep') -- helpswitch gotosleep scene
local catdoor=domoticz.devices('CatDoor') -- Catdoor
local fountain=domoticz.devices('Fountain') -- Fountain
local music=domoticz.devices('Music') -- Music player
local mtext=domoticz.devices('MusicInfo') -- Music player info text
local salt=domoticz.devices('Salt') -- Salt light
-- TIME TRIGGER
if (item.isTimer) then -- or (item.name == 'Holiday') or (item.isTimer and item.name == 'Home') or (item.isTimer and item.name == 'Sleep') or (item.isTimer and item.name == 'Music')) then
-- holiday fountain
if (holiday.state == 'Off' and fountain.state == 'Off') then
fountain.switchOn().at('10:00') --.withinMin(20)
end
--domoticz.log('color VALUE: '..someone.color)
--domoticz.log('nValue VALUE: '..someone.nValue)
--domoticz.log('holiday VALUE: '..holiday.state)
--domoticz.log('music VALUE: '..music.levelName)
--domoticz.log('catdoor VALUE: '..catdoor.state)
-- holiday music allways
if (holiday.state == 'On') then
music.switchSelector('START').at('10:00 on mon-fri') --.withinMin(20)
music.switchSelector('START').at('12:00 on sat-sun') --.withinMin(20)
end
-- holiday salt
if (holiday.state == 'Off' and salt.state == 'Off') then
salt.switchOn().at('13:57')
end
end
-- DEVICE TRIGGER
if (item.isDevice and (domoticz.time.matchesRule('at 09:00-22:00 on mon-fri') or domoticz.time.matchesRule('at 10:00-22:00 on sat-sun'))) then
-- holiday catdoor
if (item.name == 'Home' or item.name == 'Holiday') then
if (holiday.state == 'Off' and catdoor.state == 'Off' and someone.color == 1) then
catdoor.switchOn() --someone.lastUpdate.minutesAgo >= delay and
end
end
if (item.name == 'Sleep' or item.name == 'Holiday') then
if ((holiday.state == 'On' or sleep.state == 'On') and catdoor.state == 'On') then
catdoor.switchOff()
end
end
-- holiday music allways
if (item.name == 'Home') then
if (holiday.state == 'Off' and music.levelName == 'STOP' and someone.color == 1) then --someone.lastUpdate.secondsAgo <= 60 and
music.switchSelector('START')
end
end
-- holiday salt
if (item.name == 'Holiday') then
if (holiday.state == 'On' and salt.state == 'On') then
salt.switchOff()
end
end
-- update music info
if (item.name == 'Music') then
local command = '/home/pi/domoticz/scripts/bashscrips/readmusic.sh info'
local handle = io.popen(command)
local resultinfo = handle:read("*a")
handle:close()
mtext.updateText(resultinfo)
end
end
end
}
Code: Select all
return {
on = {
devices = {},
timer = {'at 3:00'},
variables = {},
scenes = {},
groups = {},
security = {},
httpResponses = {},
customEvents = {},
system = {},
},
data = {},
logging = {},
execute = function(domoticz, item)
local someone=domoticz.devices('Home') -- some one home
local music=domoticz.devices('Music') -- Music player
local holiday=domoticz.devices('Holiday') -- holiday
local sleep=domoticz.devices('Sleep') -- helpswitch gotosleep scene
local catdoor=domoticz.devices('CatDoor') -- Catdoor
local fountain=domoticz.devices('Fountain') -- Fountain
local tv=domoticz.devices('TV') -- TV light
local salt=domoticz.devices('Salt') -- Salt light
local maikel=domoticz.devices('Maikel') -- Maikel home switch
local earn=domoticz.devices('Earn') -- Earn home switch
someone.cancelQueuedCommands() -- cancel all queued commands
music.cancelQueuedCommands()
holiday.cancelQueuedCommands()
sleep.cancelQueuedCommands()
catdoor.cancelQueuedCommands()
fountain.cancelQueuedCommands()
tv.cancelQueuedCommands()
salt.cancelQueuedCommands()
maikel.cancelQueuedCommands()
earn.cancelQueuedCommands()
end
}