Page 1 of 1

domoticz.time.matchesRule

Posted: Sunday 02 December 2018 12:16
by poudenes
Hi All,

Since the domoticz.time.matchesRule is not working correct (they work on it) i got a workaround from Waanen.
But still its not working correct:

X-Mas period will start on 20/12 till 31/12 and i give every day (thats the workaround instead of 20/12-31/12)
But now it already give me the Green color...

What do i wrong?

Code: Select all

local Version = '24.10.18'

return {
    active = true,
    on = {
        devices = {SwitchDressoir},
    },
    -- logging = {marker = 'SWITCHES Control ' ..Version..'......'},
    execute = function(domoticz, device)

-- HALLOWEEN
    if (domoticz.devices(SwitchDressoir).active and domoticz.time.matchesRule 'on 23/10,24/10,25/10,26/10,27/10,28/10,29/10,30/10,31/10,1/11,2/11,3/11,4/11') then
        
            domoticz.helpers.RGB(domoticz,BulbDressoirAll,100,'Blue',nil)
            domoticz.helpers.RGB(domoticz,BulbDressoir2,100,'Purple',nil)

-- X-MAS
    elseif (domoticz.devices(SwitchDressoir).active and domoticz.time.matchesRule 'on 20/12,21/12,22/12,23/12,24/12,25/12,26/12,27/12,28/12,29/12,30/12,31/12') then

            domoticz.helpers.RGB(domoticz,BulbDressoirAll,100,'Green',nil)

-- REST VAN JAAR
    elseif (domoticz.devices(SwitchDressoir).active ) then
            
            domoticz.helpers.Kelvin(domoticz,BulbDressoirAll,nil,4000,nil)

    else
    
        domoticz.helpers.TurnOff(domoticz,BulbDressoirAll,nil,nil)
    
    end
    --domoticz.log('------------------------==<[ SWITCH '..device.idx..' On/Off ]>==--------------------', domoticz.LOG_FORCE)
end
}

Re: domoticz.time.matchesRule

Posted: Sunday 02 December 2018 12:54
by waaren
poudenes wrote: Sunday 02 December 2018 12:16 Since the domoticz.time.matchesRule is not working correct (they work on it) i got a workaround from Waanen.
Have you tested the original code (without the workaround) with a recent Beta ?
X-Mas period will start on 20/12 till 31/12 and i give every day (thats the workaround instead of 20/12-31/12)
But now it already give me the Green color...
I see that you use SwitchDressoir in the script without quotes. This imply that it is a variable but I don't see that is declared. Should it be "SwitchDressoir" or is the variable declared elsewhere ?

Re: domoticz.time.matchesRule

Posted: Sunday 02 December 2018 14:49
by poudenes
waaren wrote: Sunday 02 December 2018 12:54
poudenes wrote: Sunday 02 December 2018 12:16 Since the domoticz.time.matchesRule is not working correct (they work on it) i got a workaround from Waanen.
Have you tested the original code (without the workaround) with a recent Beta ?
X-Mas period will start on 20/12 till 31/12 and i give every day (thats the workaround instead of 20/12-31/12)
But now it already give me the Green color...
I see that you use SwitchDressoir in the script without quotes. This imply that it is a variable but I don't see that is declared. Should it be "SwitchDressoir" or is the variable declared elsewhere ?

In a global_data i have stored all the names with their IDX. Work on all my scripts so thats ok :)

Updated to latest beta with dZvents 2.4.9 and the normal way seems to work now also :)

Re: domoticz.time.matchesRule

Posted: Sunday 02 December 2018 17:16
by dannybloe
You can change the rule

Code: Select all

on 20/12,21/12,22/12,23/12,24/12,25/12,26/12,27/12,28/12,29/12,30/12,31/12
to

Code: Select all

on 20/12-31/12
and this one:

Code: Select all

on 23/10,24/10,25/10,26/10,27/10,28/10,29/10,30/10,31/10,1/11,2/11,3/11,4/11
to

Code: Select all

on 20/12-31/12,1/11-4/11
Much shorter :-)

Re: domoticz.time.matchesRule

Posted: Sunday 02 December 2018 17:22
by poudenes
dannybloe wrote: Sunday 02 December 2018 17:16

Code: Select all

on 23/10,24/10,25/10,26/10,27/10,28/10,29/10,30/10,31/10,1/11,2/11,3/11,4/11
to

Code: Select all

on 20/12-31/12,1/11-4/11
Much shorter :-)
Yes i know.. Updated to latest beta is see the short way is working now :)