domoticz.time.matchesRule

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:

domoticz.time.matchesRule

Post 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
}
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: domoticz.time.matchesRule

Post 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 ?
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: domoticz.time.matchesRule

Post 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 :)
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: domoticz.time.matchesRule

Post 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 :-)
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: domoticz.time.matchesRule

Post 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 :)
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