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.
- 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.
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”.
- 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.
- 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.