'General purpose' timers

Easy to use, 100% Lua-based event scripting framework.
ash77
Posts: 12
Joined: Wednesday 10 June 2015 22:10
Target OS: Windows
Domoticz version:
Location: United States
Contact:

Re: 'General purpose' timers

Post by ash77 » Saturday 30 June 2018 15:19

@Andyf66,
I like your idea. I think it could be further simplified to something like:

Code: Select all

on = {
    devices = {
      'Stairs Motion'
    }
  },

    execute = function(dz)
        -- Must be the motion sensor...
        domoticz.runInMins(5, function(dz)
            -- Execute my 5 minute tasks
        )
        domoticz.runInMins(10, function(dz)
            -- Execute my 10 minute tasks
        )
    end
This moves the new 'event' into the scripting engine and just exposes a callback to a lamba after a specified amount of time.

Andyf66
Posts: 24
Joined: Wednesday 13 June 2018 12:13
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: 'General purpose' timers

Post by Andyf66 » Saturday 30 June 2018 22:57

ash77 wrote:
Saturday 30 June 2018 15:19
@Andyf66,
I like your idea. I think it could be further simplified to something like:


This moves the new 'event' into the scripting engine and just exposes a callback to a lamba after a specified amount of time.
Yep, even better. Was hoping that kind of construct was available but my Lua knowledge is basic at best.

dannybloe
Posts: 1448
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi
Domoticz version:
Location: Ermelo
Contact:

Re: 'General purpose' timers

Post by dannybloe » Sunday 01 July 2018 8:24

No, that's not possible like this. dzVents doesn't have any state between script runs. It is started by Domoticz and when it is finished there is nothing that keeps running. So your delayed function doesn't live on when the script is finished (and the scope with all your variables is gone too). No, the only way this could happen is by making a round-trip through Domoticz. Just like with httpRequests.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest