'on 23/11-25/12'

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

'on 23/11-25/12'

Post 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
}
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

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

Post 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 
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

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

Post 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
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

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

Post 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
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

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

Post 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 
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

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

Post 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
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

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

Post by poudenes »

Code was correct. But Danny (builder) found a little thing in code and is investigating
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

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

Post 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
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

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

Post 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
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest