We have moved at community.getvera.com

Author Topic: Best practices for scripting my controls  (Read 262 times)

Offline GeekGoneOld

  • Jr. Member
  • **
  • Posts: 80
  • Karma: +3/-0
Best practices for scripting my controls
« on: March 01, 2019, 09:43:13 pm »
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.

2. 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".

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

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

Offline rigpapa

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1121
  • Karma: +187/-3
Re: Best practices for scripting my controls
« Reply #1 on: March 02, 2019, 09:48:35 am »
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.
Author of Reactor, DelayLight, SiteSensor, Rachio, Deus Ex Machina II, Intesis WMP Gateway, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3, Lite. Hassio, Slapdash.

Offline GeekGoneOld

  • Jr. Member
  • **
  • Posts: 80
  • Karma: +3/-0
Re: Best practices for scripting my controls
« Reply #2 on: March 02, 2019, 01:28:13 pm »
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?

Offline rigpapa

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1121
  • Karma: +187/-3
Re: Best practices for scripting my controls
« Reply #3 on: March 02, 2019, 08:36:47 pm »
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.  :D

No on UI5, I'm afraid.
Author of Reactor, DelayLight, SiteSensor, Rachio, Deus Ex Machina II, Intesis WMP Gateway, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3, Lite. Hassio, Slapdash.

Offline GeekGoneOld

  • Jr. Member
  • **
  • Posts: 80
  • Karma: +3/-0
Re: Best practices for scripting my controls
« Reply #4 on: March 03, 2019, 04:26:37 pm »

No on UI5, I'm afraid.
[/quote]
Frowny face.  I was optimistic that Reactor might be well suited to a resource constrained Vera.
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?

Offline rigpapa

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1121
  • Karma: +187/-3
Re: Best practices for scripting my controls
« Reply #5 on: March 03, 2019, 05:33:33 pm »
Quote from: rigpapa
No on UI5, I'm afraid.
Frowny face.  I was optimistic that Reactor might be well suited to a resource constrained Vera.

LOL. Well, if you could get to UI7 on that thing, you'd make the very extreme of it! :)
Author of Reactor, DelayLight, SiteSensor, Rachio, Deus Ex Machina II, Intesis WMP Gateway, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3, Lite. Hassio, Slapdash.