Timing rule as trigger no longer works lastest beta 2020.2 (build 12554)  [Solved]

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

Moderator: leecollings

Post Reply
besix
Posts: 99
Joined: Friday 25 January 2019 11:33
Target OS: Linux
Domoticz version: beta
Location: Poland
Contact:

Timing rule as trigger no longer works lastest beta 2020.2 (build 12554)

Post by besix »

Hi
I noticed that the script that worked ok in the lastest beta 2020.2 (build 12554)
stopped working.
The entire script below

Code: Select all

return 
{
    on = 
    {
     timer = {'every 2 minutes and between 4 minutes after sunrise and 58 minutes after sunset , between 59 minutes after sunset and 3 minutes after sunrise'},
     devices = {'Opady'}
    },
    logging =   
    {
        level = domoticz.LOG_DEBUG, 
        marker = 'Oczko ogród',
    },
    execute = function( dz, item)
                       
        if item.isTimer then 
            dz.log('Time trigger is: ' .. item.trigger,dz.LOG_INFO )
            if (dz.time.matchesRule('between 4 minutes after sunrise and 58 minutes after sunset') and dz.devices('Opady').state == 'Off') then
                dz.devices('Gniazdo Oczko').switchOn()
                dz.log('Oczko włączone')
            elseif (dz.time.matchesRule('between 59 minutes after sunset and 3 minutes after sunrise') or dz.devices('Opady').state == 'On') then
                dz.devices('Gniazdo Oczko').switchOff()
                dz.log('Oczko wyłączone') 
            end
    end
end
}
This is probably related to the time rule, because if I leave it only every 2 minutes, then it works

Code: Select all

return 
{
    on = 
    {
     timer = {'every 2 minutes'}
     devices = {'Opady'}
    },
    logging =   
    {
        level = domoticz.LOG_DEBUG, 
        marker = 'Oczko ogród',
    },
    execute = function( dz, item)
                       
        if item.isTimer then 
            dz.log('Time trigger is: ' .. item.trigger,dz.LOG_INFO )
            if (dz.time.matchesRule('between 4 minutes after sunrise and 58 minutes after sunset') and dz.devices('Opady').state == 'Off') then
                dz.devices('Gniazdo Oczko').switchOn()
                dz.log('Oczko włączone')
            elseif (dz.time.matchesRule('between 59 minutes after sunset and 3 minutes after sunrise') or dz.devices('Opady').state == 'On') then
                dz.devices('Gniazdo Oczko').switchOff()
                dz.log('Oczko wyłączone') 
            end
    end
end
}
What has changed in dzVents and what can I do to fix it?
Time.lua does not support timeRules ?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Timing rule as trigger no longer works lastest beta 2020.2 (build 12554)

Post by waaren »

besix wrote: Sunday 08 November 2020 8:53 timer = {'every 2 minutes and between 4 minutes after sunrise and 58 minutes after sunset , between 59 minutes after sunset and 3 minutes after sunrise'},
Although it might have done something in earlier versions, this rule was never supported. In fact I don't understand what it should do.

Should it trigger:

Code: Select all

every 2 minutes 24/7
every 1 minute between 4 minutes after sunrise and 58 minutes after sunset
every 1 minute between 59 minutes after sunset and 3 minutes after sunrise
?

Please elaborate in text when you want the script to be triggered.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Timing rule as trigger no longer works lastest beta 2020.2 (build 12554)

Post by dannybloe »

Indeed, this should be split into separate rules. And's and comma's are not supported. The reason it might have worked is purely coincidental, perhaps due to how dzVents parses the rules.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
besix
Posts: 99
Joined: Friday 25 January 2019 11:33
Target OS: Linux
Domoticz version: beta
Location: Poland
Contact:

Re: Timing rule as trigger no longer works lastest beta 2020.2 (build 12554)

Post by besix »

Thanks for the answers.
After your suggestions I changed the script and this is probably what I expect. I don't know why I made it so complicated myself.

Code: Select all

return 
{
    on = 
    {
     timer = {'every 2 minutes and between 4 minutes after sunrise and 58 minutes after sunset'},
     devices = {'Opady'}
    },
    logging =   
    {
        level = domoticz.LOG_DEBUG, 
        marker = 'Oczko ogród',
    },
    execute = function( dz, item)
                       
        if item.isTimer then 
            dz.log('Time trigger is: ' .. item.trigger,dz.LOG_INFO )
            if (dz.time.matchesRule('between 4 minutes after sunrise and 58 minutes after sunset') and dz.devices('Opady').state == 'Off') then
                dz.devices('Gniazdo Oczko').switchOn().checkFirst()
                dz.log('Oczko włączone')
            else
                dz.devices('Gniazdo Oczko').switchOff().checkFirst()
                dz.log('Oczko wyłączone') 
            end
    end
end
}
This first script, however, worked in earlier versions of dzVents
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Timing rule as trigger no longer works lastest beta 2020.2 (build 12554)

Post by waaren »

besix wrote: Sunday 08 November 2020 13:19 After your suggestions I changed the script and this is probably what I expect. I don't know why I made it so complicated myself.
Your rule

Code: Select all

'every 2 minutes and between 4 minutes after sunrise and 58 minutes after sunset'
Use an unsupported syntax.
If you want the script to be triggered every 2nd minute between 4 minutes after sunrise and 58 minutes after sunset, the rule should be

Code: Select all

'every 2 minutes between 4 minutes after sunrise and 58 minutes after sunset'
If you want the script to be triggered every two minutes 24/7 and every 1 minute between 4 minutes after sunrise and 58 minutes after sunset the rules should be

Code: Select all

'every 2 minutes',
'every minute between 4 minutes after sunrise and 58 minutes after sunrise',
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
besix
Posts: 99
Joined: Friday 25 January 2019 11:33
Target OS: Linux
Domoticz version: beta
Location: Poland
Contact:

Re: Timing rule as trigger no longer works lastest beta 2020.2 (build 12554)  [Solved]

Post by besix »

waaren wrote: Sunday 08 November 2020 13:36 If you want the script to be triggered every two minutes 24/7 and every 1 minute between 4 minutes after sunrise and 58 minutes after sunset the rules should be

Code: Select all

'every 2 minutes',
'every minute between 4 minutes after sunrise and 58 minutes after sunrise',
thanks a lot for your help. Your last tip is what I needed
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest