Notifications sent mutliple times

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

Moderator: leecollings

Post Reply
pmniemiDomFor
Posts: 8
Joined: Sunday 05 April 2020 12:39
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Contact:

Notifications sent mutliple times

Post by pmniemiDomFor »

Hi,

I have been using Domoticz for mor ethan a year and have lately taken dzVents into use in order to have more control.

My current problem is regarding my garden lights. I want them to turn on in the morning, before sunrise, and the turn of at sunrise. Similarly I turn them on in the evening at sunset and turn them off at midnight. This all worked corretly without any scripting. I added Telegram as notification channel, but often the same notification comes multiple times. Why?

No I', trying to implement this in dzVents. I start off with a few timer triggers:

Code: Select all

		timer = {
			'at sunrise',
			'at sunset',
			'at 05:30',
			'at 23:45',
			--'at 09:18',
			--'at 09:19'
		}
It seems that with those triggers the execution part of the script is run a lot of times (tens of times?) when it's is triggered. So e.g. when i tested with 09:18 activated, it was triggered correctly but many many times - the telegram notification was flooded and I actually stopped domoticz in the shell...

Apparently thre is something I don't know about the time triggers. What?

This is only a part of the log when domtoicz was running the trigger at 09:19 (that switched off my garden lights):

Code: Select all

2020-04-05 09:19:59.604 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-04-05 09:19:59.699 Status: dzVents: Info: Handling events for: "Gårdsbelysning 2", value: "Off"
2020-04-05 09:19:59.699 Status: dzVents: Info: ------ Start internal script: Gårdsbelysningen: Device: "Gårdsbelysning 2 (Aeotec Z-stick GEN5)", Index: 122
2020-04-05 09:19:59.700 Status: dzVents: Info: Gårdsbelysningen kollas...
2020-04-05 09:19:59.700 Status: dzVents: Info: Gårdsbelysningen släcktes.
2020-04-05 09:19:59.700 Status: dzVents: Info: ------ Finished Gårdsbelysningen
2020-04-05 09:19:59.701 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-04-05 09:19:59.814 Status: dzVents: Info: Handling events for: "Gårdsbelysning 2", value: "Off"
2020-04-05 09:19:59.814 Status: dzVents: Info: ------ Start internal script: Gårdsbelysningen: Device: "Gårdsbelysning 2 (Aeotec Z-stick GEN5)", Index: 122
2020-04-05 09:19:59.815 Status: dzVents: Info: Gårdsbelysningen kollas...
2020-04-05 09:19:59.816 Status: dzVents: Info: Gårdsbelysningen släcktes.
2020-04-05 09:19:59.816 Status: dzVents: Info: ------ Finished Gårdsbelysningen
2020-04-05 09:19:59.818 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-04-05 09:19:59.937 Status: dzVents: Info: Handling events for: "Gårdsbelysning 2", value: "Off"
2020-04-05 09:19:59.938 Status: dzVents: Info: ------ Start internal script: Gårdsbelysningen: Device: "Gårdsbelysning 2 (Aeotec Z-stick GEN5)", Index: 122
2020-04-05 09:19:59.938 Status: dzVents: Info: Gårdsbelysningen kollas...
2020-04-05 09:19:59.939 Status: dzVents: Info: Gårdsbelysningen släcktes.
2020-04-05 09:19:59.939 Status: dzVents: Info: ------ Finished Gårdsbelysningen
2020-04-05 09:19:59.940 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-04-05 09:20:00.031 Status: dzVents: Info: Handling events for: "Gårdsbelysning 2", value: "Off"
2020-04-05 09:20:00.031 Status: dzVents: Info: ------ Start internal script: Gårdsbelysningen: Device: "Gårdsbelysning 2 (Aeotec Z-stick GEN5)", Index: 122
2020-04-05 09:20:00.032 Status: dzVents: Info: Gårdsbelysningen kollas...
2020-04-05 09:20:00.032 Status: dzVents: Info: ------ Finished Gårdsbelysningen
2020-04-05 09:20:00.121 Status: dzVents: Info: Handling events for: "Gårdsbelysning 2", value: "Off"
2020-04-05 09:20:00.121 Status: dzVents: Info: ------ Start internal script: Gårdsbelysningen: Device: "Gårdsbelysning 2 (Aeotec Z-stick GEN5)", Index: 122
2020-04-05 09:20:00.122 Status: dzVents: Info: Gårdsbelysningen kollas...
2020-04-05 09:20:00.122 Status: dzVents: Info: ------ Finished Gårdsbelysningen 
I thought the trigger at 09:19 should be triggered/run only oncem but in my case that is not the case. Can anybody help?

Thanks,

Peik
Domoticz 2020.1, Raspberry Pi, Buster, Z-wave, Aeotec Z-stick GEN5
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Notifications sent mutliple times

Post by waaren »

pmniemiDomFor wrote: Sunday 05 April 2020 13:07 Now I am trying to implement this in dzVents. I start off with a few timer triggers:
I thought the trigger at 09:19 should be triggered/run only once
Yes that is correct.

You probably have something in the

Code: Select all

on = devices 
section...

The loglines below tells you that the device is not started by a timer trigger but by a device.

Code: Select all

2020-04-05 09:19:59.699 Status: dzVents: Info: ------ Start internal script: Gårdsbelysningen: Device: "Gårdsbelysning 2 (Aeotec Z-stick GEN5)", Index: 122
2020-04-05 09:19:59.814 Status: dzVents: Info: ------ Start internal script: Gårdsbelysningen: Device: "Gårdsbelysning 2 (Aeotec Z-stick GEN5)", Index: 122
2020-04-05 09:19:59.938 Status: dzVents: Info: ------ Start internal script: Gårdsbelysningen: Device: "Gårdsbelysning 2 (Aeotec Z-stick GEN5)", Index: 122
2020-04-05 09:20:00.031 Status: dzVents: Info: ------ Start internal script: Gårdsbelysningen: Device: "Gårdsbelysning 2 (Aeotec Z-stick GEN5)", Index: 122
2020-04-05 09:20:00.121 Status: dzVents: Info: ------ Start internal script: Gårdsbelysningen: Device: "Gårdsbelysning 2 (Aeotec Z-stick GEN5)", Index: 122
If the script is triggered by a timer you see something like

Code: Select all

2020-04-05 13:16:00.353  Status: dzVents: Info: ------ Start internal script: (dzVents) loop over devices:, trigger: "every minute"
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
pmniemiDomFor
Posts: 8
Joined: Sunday 05 April 2020 12:39
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Contact:

Re: Notifications sent mutliple times

Post by pmniemiDomFor »

Thanks for the quick reply and for pointing me in the right direction!

Yes, I actually have a device trigger as well, for some reason, because my intention was really to do this only based on time triggers... So what happens now, is that the script is triggered by time, changes the state of the switch, which triggers the device and then starts looping... I guess.

Thanks a lot.

By the way, speaking of time triggers, should it be possible to trigger somehting "every 6 days"? I tried that, but it didn't work. Instead I did it with a daily trigger and a counter in the data section. It accomplishes the same thing, but is less elegant. :-)

-Peik
Domoticz 2020.1, Raspberry Pi, Buster, Z-wave, Aeotec Z-stick GEN5
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Notifications sent mutliple times

Post by waaren »

pmniemiDomFor wrote: Sunday 05 April 2020 13:33 By the way, speaking of time triggers, should it be possible to trigger somehting "every 6 days"? I tried that, but it didn't work. Instead I did it with a daily trigger and a counter in the data section. It accomplishes the same thing, but is less elegant. :-)
"Elegant" is a subjective term :D

Code: Select all

return 
{
    active = function() 
        local day = 86400       -- number of seconds in a day
        local offset = 3        -- if you want the cycle to start at april 5th 2020, you need an offset of 3 
        local frequency = 6     -- every "frequency" th  day 
        
        -- Remove the print when working OK as this will be printed quite often 
         print ( ( math.floor( os.time() / day + offset ) % frequency == 0 ) and 'will execute today'  or 'will not exexute today')
         
        -- this will evaluate to true every 6th day if you want it to start at april 5th 2020 you need an offset of 3 
        return  math.floor( os.time() / day + offset ) % frequency == 0 
    end,

    on = 
    { 
        timer =
        {
            'at 15:30', -- change to the time you want
        },
    },

    logging = 
    {
        level = domoticz.LOG_DEBUG,
        marker = 'every 6th day' 
    },

    execute = function(dz)
        dz.log('Was it already 6 days ago ?' ,dz.LOG_DEBUG)
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
pmniemiDomFor
Posts: 8
Joined: Sunday 05 April 2020 12:39
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Contact:

Re: Notifications sent mutliple times

Post by pmniemiDomFor »

Wow, maybe that solution is elegant as well, certainly more complicated. :-) I would never have thought of a solution like that. :-)

-Peik
Domoticz 2020.1, Raspberry Pi, Buster, Z-wave, Aeotec Z-stick GEN5
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests