Page 1 of 1

'on 23/11-25/12'

Posted: Sunday 21 October 2018 10:27
by poudenes
Hi ALl,

Can i use this time option 'on 23/11-25/12' in a IF statement or only in a timer?

cheers,
Peter

I tried this:

Code: Select all

local Version = '18.07.18'

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

    if (domoticz.devices(SwitchDressoir).active) then 
        
        if ('on 22/10-31/10') then -- HALLOWEEN

            domoticz.helpers.RGB(domoticz,BulbDressoirAll,100,'Blue',nil)
            domoticz.helpers.RGB(domoticz,BulbDressoir2,100,'Purple',nil)
            
        elseif ('on 20/12-31/12') then -- XMAS
        
            domoticz.helpers.RGB(domoticz,BulbDressoirAll,100,'Green',nil)
            
        else -- NORMAL
            
            domoticz.helpers.RGB(domoticz,BulbDressoirAll,100,'White',nil)
        
        end

    elseif (not domoticz.devices(SwitchDressoir).active) then
        domoticz.helpers.TurnOff(domoticz,BulbDressoirAll,nil,nil)
    end
    --domoticz.log('------------------------==<[ SWITCH '..device.idx..' On/Off ]>==--------------------', domoticz.LOG_FORCE)
end
}

Re: 'on 23/11-25/12'

Posted: Sunday 21 October 2018 10:51
by waaren
poudenes wrote: Sunday 21 October 2018 10:27 Hi ALl,

Can i use this time option 'on 23/11-25/12' in a IF statement or only in a timer?
You can but you have to use

Code: Select all

if domoticz.time.matchesRule("on 23/11-25/12") then 

Re: 'on 23/11-25/12'

Posted: Sunday 21 October 2018 10:57
by poudenes
waaren wrote: Sunday 21 October 2018 10:51
poudenes wrote: Sunday 21 October 2018 10:27 Hi ALl,

Can i use this time option 'on 23/11-25/12' in a IF statement or only in a timer?
You can but you have to use

Code: Select all

if domoticz.time.matchesRule("on 23/11-25/12") then 
Thanks for support, but does not work. Tried different things

Code: Select all

if domoticz.time.matchesRule ("on 23/10-31/10") then

Code: Select all

if (domoticz.time.matchesRule "on 23/10-31/10") then

Code: Select all

if (domoticz.time.matchesRule 'on 23/10-31/10') then

Re: 'on 23/11-25/12'

Posted: Sunday 21 October 2018 11:20
by poudenes
When i have this:

Code: Select all

        if (domoticz.time.matchesRule ('on 10/10 - 20/10')) then -- XMAS
            domoticz.helpers.RGB(domoticz,BulbDressoirAll,100,'Green',nil)
        elseif (domoticz.time.matchesRule ('on 25/12 - 31/12')) then -- HALLOWEEN
            domoticz.helpers.RGB(domoticz,BulbDressoirAll,100,'Blue',nil)
            domoticz.helpers.RGB(domoticz,BulbDressoir2,100,'Purple',nil)
        else -- NORMAL
            domoticz.helpers.RGB(domoticz,BulbDressoirAll,100,'White',nil)
        end
Then it skip first IF but react on second. First period is in past. Second is in future.
strange... hehe

Re: 'on 23/11-25/12'

Posted: Sunday 21 October 2018 13:16
by waaren
poudenes wrote: Sunday 21 October 2018 11:20 When i have this:

Code: Select all

        if (domoticz.time.matchesRule ('on 10/10 - 20/10')) then -- XMAS
            domoticz.helpers.RGB(domoticz,BulbDressoirAll,100,'Green',nil)
        elseif (domoticz.time.matchesRule ('on 25/12 - 31/12')) then -- HALLOWEEN
            domoticz.helpers.RGB(domoticz,BulbDressoirAll,100,'Blue',nil)
            domoticz.helpers.RGB(domoticz,BulbDressoir2,100,'Purple',nil)
        else -- NORMAL
            domoticz.helpers.RGB(domoticz,BulbDressoirAll,100,'White',nil)
        end
Then it skip first IF but react on second. First period is in past. Second is in future.
strange... hehe
Hi Peter,
Leave out the spaces (change 10/10 - 20/10 to 10/10-20/10) and maybe related to your domoticz / dzVents version.
this code behave as expected with dzVents 2.4.7

Code: Select all

return {
          on   = { timer = { "every minute"}},
                   
    execute = function(domoticz)
        if domoticz.time.matchesRule("on 20/10-23/10") then
            domoticz.log("Hi there. It is now " .. domoticz.time.raw)
        end
    end 
}

Re: 'on 23/11-25/12'

Posted: Sunday 21 October 2018 13:25
by poudenes
I'm running on latest beta. (Updated the morning) and tried also without spaces. Will try later... Now on my way to fright night Walibi 🤪


Verzonden vanaf mijn iPhone met Tapatalk Pro

Re: 'on 23/11-25/12'

Posted: Monday 22 October 2018 14:50
by poudenes
Code was correct. But Danny (builder) found a little thing in code and is investigating

Re: 'on 23/11-25/12'

Posted: Monday 22 October 2018 16:40
by waaren
poudenes wrote: Monday 22 October 2018 14:50 Code was correct. But Danny (builder) found a little thing in code and is investigating
Until Danny fixed it, you could use

Code: Select all

       if domoticz.time.matchesRule('on 10/10,11/10/12/10,13/10,14/10,15/10,16/10,17/10,18/10,19/10,20/10')  then -- HALLOWEEN
             domoticz.helpers.RGB(domoticz,BulbDressoirAll,100,'Green',nil)
       elseif (domoticz.time.matchesRule ('on 25/12,26/12,27/12,28/12,29/12,30/12,31/12,')) then -- X-MAS
            domoticz.helpers.RGB(domoticz,BulbDressoirAll,100,'Blue',nil)
            domoticz.helpers.RGB(domoticz,BulbDressoir2,100,'Purple',nil)
       else -- NORMAL
            domoticz.helpers.RGB(domoticz,BulbDressoirAll,100,'White',nil)
        end
    
as workaround

Re: 'on 23/11-25/12'

Posted: Monday 22 October 2018 16:52
by poudenes
waaren wrote: Monday 22 October 2018 16:40
poudenes wrote: Monday 22 October 2018 14:50 Code was correct. But Danny (builder) found a little thing in code and is investigating
Until Danny fixed it, you could use

Code: Select all

       if domoticz.time.matchesRule('on 10/10,11/10/12/10,13/10,14/10,15/10,16/10,17/10,18/10,19/10,20/10')  then -- HALLOWEEN
             domoticz.helpers.RGB(domoticz,BulbDressoirAll,100,'Green',nil)
       elseif (domoticz.time.matchesRule ('on 25/12,26/12,27/12,28/12,29/12,30/12,31/12,')) then -- X-MAS
            domoticz.helpers.RGB(domoticz,BulbDressoirAll,100,'Blue',nil)
            domoticz.helpers.RGB(domoticz,BulbDressoir2,100,'Purple',nil)
       else -- NORMAL
            domoticz.helpers.RGB(domoticz,BulbDressoirAll,100,'White',nil)
        end
    
as workaround
Love this creativity !!! :D