Best practices for scripting my controls

I have a number of relatively simple controls I want to script. Things like unlocking the door when someone comes home (geofence trigger) after an absence of more than 10 minutes then relocking it 15 minutes later as long as it hasn’t been operated manually or automatically in the meantime. I don’t see too much difficulty in doing this as I spent most of my carreer turning english requests into programming.

The thing I want some guidance with is the best way to do this. I’m using UI5.

I have come up with four obvious ways but want to know the pros and cons.

  1. PLEG, Reactor etc.

I have used PLEG but not reactor and I know the significant benefits of PLEG. I commend Richard on an awesome design. Problem is I am VERY memory constrained and it seem to me that I can save much if I program my controls by hand.

  1. Scenes

I could use a scene for each control and put the scripting in the scene. The scene configuration UI could also handle some of the things I would otherwise program. Seems, though, that I would find it a bit less clean to have a mix of scene UI “code” and my lua code. As you see from my scenarion above, as scenes my control can be considerably more complicated than “humidity high - run fan until 10 minutes after humidity low”.

  1. Startup Lua

Seems to me startup lua is not intended to contain my controls, just global stuff that might apply to multiple controls (e.g. a library of generic functions I might use). Still, I could make a module for each control. I suspect I can’t trust the environment at startup and might have to use a callback to start up 30s later.

  1. Make a device for each control.

Although that may work, sounds pretty wasteful. It would allow me to make a simple UI for setting parameters (e.g. 20 minute delay instead of 15 etc.). Still, sounds like devices are more keyed toward multiple instances whereas scenes are clearly single instances.

I’m sure you can see where I’m coming from. Let me know your thoughts.

Keith

Try Reactor. I do a great deal of testing of Reactor on a VeraLite, the most memory- and CPU-constrained device I’ve been able to get my hands on. If it doesn’t run well there, I fix it. Reactor is designed from the ground up to be light on system resources, and very fast in response to events. The only caveat I would make is that it is best configured using a (modern) desktop browser–there’s a good bit of fairly demanding JavaScript in the UI, and the quantity of information presented in some tabs is more suited to a desktop than mobile layout.

Well, I’ve got you beat on the most memory and CPU constrained device. I’m on a Vera2. That means I’m also UI constrained to UI5. Does Reactor work on UI5?

Sorry, you win. :smiley:

No on UI5, I’m afraid.

No on UI5, I’m afraid.
[/quote]
Frowny face. I was optimistic that Reactor might be well suited to a resource constrained Vera.

[quote author=rigpapa link=topic=122921.msg446461#msg446461 date=1551577007]

[quote author=GeekGoneOld link=topic=122921.msg446404#msg446404 date=1551551293]
Well, I’ve got you beat on the most memory and CPU constrained device. I’m on a Vera2. That means I’m also UI constrained to UI5. Does Reactor work on UI5?

Frowny face. I was optimistic that Reactor might be well suited to a resource constrained Vera.[/quote]

LOL. Well, if you could get to UI7 on that thing, you’d make the very extreme of it! :slight_smile: