hestia wrote: Monday 13 January 2020 8:37
another question regarding between, I don't understand why the between condition reports false in the following case...
local timeConditionT1ToT2 = (dz.time.matchesRule('between wakeUpTime1 and wakeUpTime2'))
local timeConditionT1ToT2 = (now.matchesRule('between wakeUpTime1 and wakeUpTime2'))
A couple of observations:
- dz.time and now are the same in your script.
- Starting dzVents version 2.5.4 (domotic version >= V4.11593 You can also use
Code: Select all
local wakeUpTime1 = dz.time.makeTime(dz.time.rawdate .. " " .. TIME_W1 ) -- No need for local Time = require('Time'), local now = Time()
- On the rules you use in matchesRule(); you include wakeUpTime1 and wakeUpTime2. These are just names of the just created time objects. and entered within a string they will not influence anything. You probably want something like
Code: Select all
local timeRule = 'between ' .. wakeUpTime1.rawTime .. ' and ' .. wakeUpTime2.rawTime' -- not the complete object but the attribute rawTime
local timeConditionT1ToT2 = dz.time.matchesRule(timeRule)
Your post triggered me to check the dzVents Time module again and I identified some small glitches. They should be OK in the latest Beta
( domoticz V4.11609)
See below a small test script.
Code: Select all
return {
on =
{
timer =
{
'every minute'
},
devices =
{
'timeTrigger'
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = DOMAIN
},
execute = function(dz, item )
local wakeUpTime1 = '08:25'
local wakeUpTime1Object = dz.time.makeTime(dz.time.rawDate .. " " .. wakeUpTime1 ..':00' ) -- dzVents >= 2.5.4
local wakeUpTime2Object = wakeUpTime1Object.addMinutes(15)
dz.log('now : ' .. dz.time.raw, LOG_DEBUG)
dz.log('wakeUpTime1 : ' .. wakeUpTime1Object.raw, LOG_DEBUG)
dz.log('wakeUpTime2 : ' .. wakeUpTime2Object.raw, LOG_DEBUG)
local function checkRule(timeObject, check)
dz.log('Does ' .. timeObject.rawTime .. ' matchesRule('.. check .. ') ==> ' .. tostring(timeObject.matchesRule(check)),dz.LOG_DEBUG)
end
timeObjects =
{
dz.time,
wakeUpTime1Object,
wakeUpTime2Object,
}
RulesToCheck =
{
'at 08:25-8:40' ,
'at 08:40-08:25' ,
'at 08:40-7:25' ,
'at 19:25-12:40' ,
'at 11:25-11:45' ,
'at 12:40-11:40' ,
'between 8:25 and 8:40' ,
'between 08:25, 08:40',
'between 8:40 and 8:20',
'between 08:40:00 and 08:20:00',
'between ' .. wakeUpTime1Object.rawTime .. ' and ' .. wakeUpTime2Object.rawTime,
}
for _, timeObject in ipairs(timeObjects) do
for _, rule in ipairs(RulesToCheck) do
checkRule(timeObject,rule)
end
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>>
dzVents wiki