sunset does not work Topic is solved

On various Hardware and OS systems: pi / windows / routers / nas, etc

Moderator: leecollings

Post Reply
robbert1977
Posts: 15
Joined: Saturday 18 April 2020 22:12
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

sunset does not work

Post by robbert1977 »

Hi all,

Ok I tried my first easy lua script today for switching garden lights at sunset and switch them off a few hours after.
When during testing I used a time it worked perfectly. When I us trigger 'at sunset' it doesn't work. If I use ' at nighttime' is does work.
So for the ease I made a short test script and I really don't know why sunset doesn't work it should I think.

Ok so according to domoticz the sunset was today at 20:42
I checked sunsetInMinutes to check sunset was indeed calculated correctly

Code: Select all

 return {
        active = true,
        on = {
          timer = {
          -- 'on at nighttime every 2 minutes'  -- WORKED
          -- 'on at 5 minutes before sunset'   -- DIDN't WORK at 20:37
          -- 'on at sunset'  -- DIDN't WORK at 20:42
          -- 'on 18/4 at 21:19'  -- WORKED
          }
        },
        execute = function(domoticz)
        local sunset = domoticz.time.sunsetInMinutes
        domoticz.log('sunset works ' ..sunset.. ' sunset')
      end
    } 
Log with minute time sunset

Code: Select all

2020-04-18 22:00:00.095 Status: dzVents: Info: ------ Start external script: test.lua:, trigger: "on at nighttime every 2 minutes"
2020-04-18 22:00:00.095 Status: dzVents: Info: sunset works 1242 sunset
2020-04-18 22:00:00.095 Status: dzVents: Info: ------ Finished test.lua
You would expect that you would see the sunset with following as a trigger.. but it ain't
-- Code --
timer = {
'on after sunset every minute',
'on at nighttime every 5 minutes'

-- Log --
2020-04-18 22:33:25.568 (Buienradar) General/Custom Sensor (Rainfall next Hour)
2020-04-18 22:34:25.557 (Buienradar) General/Custom Sensor (Next Rainshower Leadtime)
2020-04-18 22:35:00.487 Status: dzVents: Info: ------ Start external script: test.lua:, trigger: "on at nighttime every 5 minutes"
2020-04-18 22:35:00.487 Status: dzVents: Info: sunset works 1242 sunset
2020-04-18 22:35:00.487 Status: dzVents: Info: ------ Finished test.lua



any help would be appreciated.
Kind regards robbert
Raspberry Pi 4
domoticzVersion: 2020.2
dzVentsVersion: 3.0.2
OpenZWave USB: 1.6-1033-g3661f170
RFXCOM - RFXtrx433 USB: Pro XL1/1043, Noise: 109 dB
Homebridge - Siri integration
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: sunset does not work

Post by waaren »

robbert1977 wrote: Saturday 18 April 2020 22:20 When during testing I used a time it worked perfectly. When I us trigger 'at sunset' it doesn't work. If I use ' at nighttime' is does work.
Please always include your domoticz / dzVents version.

a modified test.

Code: Select all

return 
{
    on = 
    {
        timer = 
        {
          'on at nighttime every 2 minutes',      -- WORKED (the on is ignored here the right syntaxis is 'at nighttime every 2 minute'
          'at 124 minutes after sunset',           -- DIDN't WORK at 20:37 
          'at sunset',                          -- DIDN't WORK at 20:42
          'on 18/4 at 22:51',                      -- WORKED
         },
        },
        
    execute = function(domoticz, item)
        domoticz.log('sunset in minutes works: ' .. domoticz.time.sunsetInMinutes)
     
        domoticz.log ('domoticzVersion: '  .. domoticz.settings.domoticzVersion)
        domoticz.log ('dzVentsVersion: '  .. domoticz.settings.dzVentsVersion)
        domoticz.log ('triggered by : '  .. item.trigger)
        
    end
} 
My results from the above script (sunset time at my location 18/4/2020 20:45)
Spoiler: show

Code: Select all

2020-04-18 22:48:00.257  Status: dzVents: Info: ------ Start internal script: dz time triggers:, trigger: "on at nighttime every 2 minutes"
2020-04-18 22:48:00.257  Status: dzVents: Info: sunset in minutes works: 1245
2020-04-18 22:48:00.257  Status: dzVents: Info: domoticzVersion: 2020.1 (build 11935)
2020-04-18 22:48:00.257  Status: dzVents: Info: dzVentsVersion: 3.0.2
2020-04-18 22:48:00.257  Status: dzVents: Info: triggered by : on at nighttime every 2 minutes
2020-04-18 22:48:00.257  Status: dzVents: Info: ------ Finished dz time triggers

2020-04-18 22:49:00.282  Status: dzVents: Info: ------ Start internal script: dz time triggers:, trigger: "at 124 minutes after sunset"
2020-04-18 22:49:00.283  Status: dzVents: Info: sunset in minutes works: 1245
2020-04-18 22:49:00.283  Status: dzVents: Info: domoticzVersion: 2020.1 (build 11935)
2020-04-18 22:49:00.283  Status: dzVents: Info: dzVentsVersion: 3.0.2
2020-04-18 22:49:00.283  Status: dzVents: Info: triggered by : at 124 minutes after sunset
2020-04-18 22:49:00.283  Status: dzVents: Info: ------ Finished dz time triggers

2020-04-18 22:50:00.301  Status: dzVents: Info: ------ Start internal script: dz time triggers:, trigger: "on at nighttime every 2 minutes"
2020-04-18 22:50:00.301  Status: dzVents: Info: sunset in minutes works: 1245
2020-04-18 22:50:00.301  Status: dzVents: Info: domoticzVersion: 2020.1 (build 11935)
2020-04-18 22:50:00.302  Status: dzVents: Info: dzVentsVersion: 3.0.2
2020-04-18 22:50:00.302  Status: dzVents: Info: triggered by : on at nighttime every 2 minutes
2020-04-18 22:50:00.302  Status: dzVents: Info: ------ Finished dz time triggers

2020-04-18 22:51:00.320  Status: dzVents: Info: ------ Start internal script: dz time triggers:, trigger: "on 18/4 at 22:51"
2020-04-18 22:51:00.320  Status: dzVents: Info: sunset in minutes works: 1245
2020-04-18 22:51:00.320  Status: dzVents: Info: domoticzVersion: 2020.1 (build 11935)
2020-04-18 22:51:00.320  Status: dzVents: Info: dzVentsVersion: 3.0.2
2020-04-18 22:51:00.320  Status: dzVents: Info: triggered by : on 18/4 at 22:51
2020-04-18 22:51:00.321  Status: dzVents: Info: ------ Finished dz time triggers
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
robbert1977
Posts: 15
Joined: Saturday 18 April 2020 22:12
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: sunset does not work

Post by robbert1977 »

Hi,

Thanks for your fast reply and help :P

Code: Select all

return
{
    on =
    {
        timer =
        {
          'on at nighttime every 2 minutes',      -- WORKED (the on is ignored   'at nighttime every 1 minute',
          'at 124 minutes after sunset',           -- DIDN't WORK at 20:37
          'at sunset',                          -- DIDN't WORK at 20:42
          'on 18/4 at 22:51',                      -- WORKED
         },
        },

    execute = function(domoticz, item)
        domoticz.log('sunset in minutes works: ' ..domoticz.time.sunsetInMinutes)

        domoticz.log ('domoticzVersion: '  ..domoticz.settings.domoticzVersion)
        domoticz.log ('dzVentsVersion: '  .. domoticz.settings.dzVentsVersion)
        domoticz.log ('triggered by : '  .. item.trigger)

    end
}

Code: Select all

2020-04-18 23:16:00.431 Status: dzVents: Info: ------ Start external script: test2.lua:, trigger: "on at nighttime every 2 minutes"
2020-04-18 23:16:00.431 Status: dzVents: Info: sunset in minutes works: 1242
2020-04-18 23:16:00.431 Status: dzVents: Info: domoticzVersion: 2020.1
2020-04-18 23:16:00.431 Status: dzVents: Info: dzVentsVersion: 3.0.1
2020-04-18 23:16:00.431 Status: dzVents: Info: triggered by : on at nighttime every 2 minutes
2020-04-18 23:16:00.431 Status: dzVents: Info: ------ Finished test2.lua
seems the minutes with an s is not ignored?

second could this work? 'on after sunset every minute' ?
Raspberry Pi 4
domoticzVersion: 2020.2
dzVentsVersion: 3.0.2
OpenZWave USB: 1.6-1033-g3661f170
RFXCOM - RFXtrx433 USB: Pro XL1/1043, Noise: 109 dB
Homebridge - Siri integration
robbert1977
Posts: 15
Joined: Saturday 18 April 2020 22:12
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: sunset does not work

Post by robbert1977 »

It worked :P

Code: Select all

return
{
    on =
    {
        timer =
        {
          'on at nighttime every 2 minutes',
          'at 163 minutes after sunset',
          'at 164 minutes after sunset',
          'at 165 minutes after sunset',
          'at sunset',
          'on 18/4 at 22:51',
         },
        },

    execute = function(domoticz, item)
        domoticz.log('sunset in minutes works: ' ..domoticz.time.sunsetInMinutes)

        domoticz.log ('domoticzVersion: '  ..domoticz.settings.domoticzVersion)
        domoticz.log ('dzVentsVersion: '  .. domoticz.settings.dzVentsVersion)
        domoticz.log ('triggered by : '  .. item.trigger)

    end
}

Code: Select all

2020-04-18 23:25:41.254 Status: User: robbert initiated a scene/group command
2020-04-18 23:26:00.536 Status: dzVents: Info: ------ Start external script: test2.lua:, trigger: "on at nighttime every 2 minutes"
2020-04-18 23:26:00.536 Status: dzVents: Info: sunset in minutes works: 1242
2020-04-18 23:26:00.536 Status: dzVents: Info: domoticzVersion: 2020.1
2020-04-18 23:26:00.536 Status: dzVents: Info: dzVentsVersion: 3.0.1
2020-04-18 23:26:00.536 Status: dzVents: Info: triggered by : on at nighttime every 2 minutes
2020-04-18 23:26:00.536 Status: dzVents: Info: ------ Finished test2.lua
2020-04-18 23:27:00.540 Status: dzVents: Info: ------ Start external script: test2.lua:, trigger: "at 165 minutes after sunset"
2020-04-18 23:27:00.541 Status: dzVents: Info: sunset in minutes works: 1242
2020-04-18 23:27:00.541 Status: dzVents: Info: domoticzVersion: 2020.1
2020-04-18 23:27:00.541 Status: dzVents: Info: dzVentsVersion: 3.0.1
2020-04-18 23:27:00.541 Status: dzVents: Info: triggered by : at 165 minutes after sunset
2020-04-18 23:27:00.541 Status: dzVents: Info: ------ Finished test2.lua
Raspberry Pi 4
domoticzVersion: 2020.2
dzVentsVersion: 3.0.2
OpenZWave USB: 1.6-1033-g3661f170
RFXCOM - RFXtrx433 USB: Pro XL1/1043, Noise: 109 dB
Homebridge - Siri integration
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: sunset does not work

Post by waaren »

robbert1977 wrote: Saturday 18 April 2020 23:17 Could this work? 'on after sunset every minute' ?
what do you want? After sunset until midnight or every minute between sunset and sunrise ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
robbert1977
Posts: 15
Joined: Saturday 18 April 2020 22:12
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: sunset does not work

Post by robbert1977 »

actually on certain months for a certain amount of time:

'at 179 minutes after sunset',
'at 182 minutes after sunset on 1/1-1/5',
'on 1/1-1/5 at 178 minutes after sunset'

looking for the right syntax I guess :P
Raspberry Pi 4
domoticzVersion: 2020.2
dzVentsVersion: 3.0.2
OpenZWave USB: 1.6-1033-g3661f170
RFXCOM - RFXtrx433 USB: Pro XL1/1043, Noise: 109 dB
Homebridge - Siri integration
robbert1977
Posts: 15
Joined: Saturday 18 April 2020 22:12
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: sunset does not work

Post by robbert1977 »

ok so..

'on 1/1-1/5 at 23:50' works

'on 1/1-1/5 at 178 minutes after sunset' doesn't work

'at 188 minutes after sunset on 1/1-1/5' works

that's where I really went wron as time at the end works but sunset at the end doesn't

thanks for your time!
Raspberry Pi 4
domoticzVersion: 2020.2
dzVentsVersion: 3.0.2
OpenZWave USB: 1.6-1033-g3661f170
RFXCOM - RFXtrx433 USB: Pro XL1/1043, Noise: 109 dB
Homebridge - Siri integration
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: sunset does not work

Post by waaren »

robbert1977 wrote: Saturday 18 April 2020 23:45 looking for the right syntax I guess :P
Check the timer trigger rules at the wiki
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest