Ezlo Plus: using timer in scene scripts

As I found, it’s not possible to run a lua code that interacts with timer (and turns off device after computed time) from scene scripts. Getting the error:
2021-10-11 01:33:17.211120 ERROR: access to a timer module is prohibited from anonymous plugins

Is there a way to allow using timer module (or similar) in scene scripts?

Greetings, Erick

Can you let me know an example of what you are trying to set and the expected result?

Hello, @Erick.

Anonymous plugins (lua scripts in the Meshbots section of Ezlogic) are not allowed to do asynchronous stuff. They were meant to handle one-step actions that can be performed during a single call.
The usage of modules that provide such services is restricted.

If you need to use a timer function from Lua, it should be a fully-featured plugin.
In Meshbots API there is a possibility to call scripts of a plugin from scenes, but, as far as I remember, it’s not supported by UI.

Maybe, you can use the alternative way.

If you have an event, and after it you need to run a delayed action after a constant delay, you can just create a delayed action. It’s possible to postpone action execution for some period.

Example:
when: event1 is triggered;
then: run action1 delayed(20 sec).

The action1 can be anything.

On my Vera Plus there was a plugin called “Count Down Timer”. I used this plugin with my house alarm setup using Z-Wave door sensors etc.

When the house is “armed” using the House Modes Away mode. Then when the front door is opened the count down timer is started and lasts for 60 seconds.

This means I have 60 seconds to disarm the house, this puts Vera in to Home Mode and disarms all the security sensors etc.

If the 60 seconds count down timer expires and I have not disarmed the house, then a scene runs a burglar alarm function and would sound the siren send me notifications and do other stuff as well.

I don’t know how to replicate this functionality on the Ezlo platform.

This was the old thread for the Vera plugin. Maybe we need a similar plugin for the Ezlo platform?

Looks like mine is set to 120 secs.

Seems you are duplicating your burglar alarm functionality. Most alarms have inherent delay period to enter your code before the alarm is sounded. Or are you using Vera for a makeshift alarm of sorts?

Regardless I think you could accomplish the above with a virtual switch. When the door in question is opened (use it as a meshbot trigger) you turn on the Virtual switch (say call it doorHold) in precisely 60 seconds (put 60 second delay in the action portion).

Then have another meshbot that triggers on the setting of the virtual switch (doorHold) AND “Arm State”. If true the alarm is fired, (meaning you didn’t reset “Armed” in time). Then add some more logic in both true and false actions (add another step) to reset the VSwitch (doorHold) back to false for next time, perhaps with a couple second delay on each to avoid a race condition.

I use virtual switches technique for asynchronous events I want to make “sticky”. Things like door switches and motion sensors.

Yes doing that with Z-Wave door sensors. I dont have a proper alarm system.

Thanks for the suggestions I will have a play about with it.

Then add a cleanup meshbot to turn off alarm siren after x minutes… No need to torture your neighbors…

Maybe a delayed (secondary) action after the siren turns on, to turn off the siren say 5 minutes after sounding it.

Hello, @cw-kid

It’s done for you via the House Modes security subsystem.
It has an Entry Delay parameter.
It starts a countdown when one of the armed sensors is tripped.
It stops the timer and prevents all security-related consequences when the system is disarmed.
It notifies UI and plugins (wip) about these events.

All that you’ve listed. No need to invent it manually.
You won’t be able to repeat it manually. Or, the approach won’t be accurate and will break on any change, like broken device, etc.

If you need to do something custom during the alarm phase, we’ll provide a condition to detect alarm phases.
We are heading to make security reactions tunable. It’ll be possible to use alarmed phases to add functionality above both in meshbots and lua plugins.

Alexey

I think the reason I kind of did it manually on the Vera system and used that Count Down Timer plugin was because I also need to run scenes when the House Modes changed.

I don’t think with the standard House Modes in Vera and on Ezlo you can also in addition run a scene? This was the problem / limitation I think. So that might be a good feature request !

I think this is my current Vera Plus / MSR rules setup.

  1. An armed door sensor is tripped e.g. front door is opened.

  2. This then triggers an MSR rule / scene called " Burglar Alarm".
    This rule has various actions, the first of them is to start the 120 seconds Count Down Timer, other actions include waking an Android wall mounted tablet and navigating to a certain page in my dashboard app, sending a TTS to a speaker that says “Alarm activated you have 2 minutes to Disarm”

  3. I then have a second rule called " Burglar Alarm Delayed" its trigger is that the Count Down Timer has expired. So this means I did not disarm the house in time.
    This rules actions does all kind of things like, sounds the siren, starts camera recording, does a condition check to see if its Night time or not? If its night time then it also turns on all lights inside and outside the house, Start LAPD Animation on Light Strips (Fibaro RGBW modules), calls my phone via CallMeBot with a TTS saying “Burglar Alarm Triggered”, sends a notification to my Telegram saying “Burglar Alarm Triggered”.

  4. Alternatively to the Burglar Alarm being Triggered, if I did disarm the house in time before the 120 seconds ran out, then I run another scene called “Stop Burglar Alarm” this cancels the Count Down Timer, thus stopping the rule in step 3 from happening and also puts Vera in to Home mode.
    Any scenes that cancel the alarm are pin code protected in my dashboard app also.

You cannot do all that in Vera or Ezlo just by changing the standard House Mode from Away to Home etc.

Which is why I must of needed to use that Count Down Timer plugin instead.

Where?

There is currently nothing in the Ezlogic web UI to do with House Modes, so looking in the Android MIOS app instead I don’t see it.

The only thing I can see is when you go to “My Controllers” and say I select my Ezlo Plus then I see a “House Modes” menu item, if you click that it then lists the four different House Modes however nothing seems to happen when you click on them.

Ok that sounds like a trigger in a Meshbot rule we might be able to use.

https://log.ezlo.com/new/hub/scenes/changelog/#advanced_scenes167

They are in API, not in UI.
First one allows to detect that house modes have specific phase: entry delay, main (security event active phase), or security event is bypassed.
The second one is true during the stitch to another, armed mode. It’s about exit delay, exit time.