Author Topic: New Plugin: Reactor  (Read 3701 times)

Offline rigpapa

  • Sr. Member
  • ****
  • Posts: 467
  • Karma: +66/-0
New Plugin: Reactor
« on: June 15, 2018, 05:41:19 pm »
Lately there have been a lot of requests for assistance with conceptually simple triggering tasks that remain outside the reach of Vera's built-in trigger conditions for scenes. Many have also voiced a resistance to using Lua or PLEG for various reasons (learning curve, resource constraints, etc.). I have also fielded a lot of inquiries about how to do certain triggering tasks for DelayLight. As I pondered these issues, and in particular considered the value of making more capability in this area separate from DelayLight, I decided to take a stab at my own version of a logic plugin.

This is Reactor. Reactor is meant to be a milestone along the power path of GUI-based logic controllers between Vera's native scene triggers and the almighty PLEG. It responds to a set of configurable conditions, implementing the semantics of a motion/door sensor (aka the SecuritySensor1 service), and so can be used to trigger scenes, etc. Users create trip conditions in a simple GUI. Conditions live in one or more "condition groups." For a Reactor Sensor to be tripped, all of the conditions in any of the groups must be met (i.e. AND between conditions within a group, OR between groups). As a single-instance plugin, it controls all of its timers from a single copy of the core parent code, making it very efficient on your system resources.

Here are some typical use cases one could address with Reactor, taken from recent discussions:
  • Trigger a notification or scene if the garage door is left open for more than 5 minutes between the hours of 10am and 6am;
  • Trigger a scene to run at 5am on the 2nd Sunday of March and 1st Sunday of November every year (US DST change);
  • Trigger a scene when the house is in Away or Vacation mode and the Nest thermostat leaves "Away" mode;
  • Trigger a notification when a child enters the home and a parent is not home (latchkey);
  • Turn off a light or fan that's controlled by a motion sensor when the sensor's untrip message has been missed and the light has been on too long.
Reactor can be installed from the Vera Plugin Marketplace, or for users of ALTUI, via the AltAppStore.

Please use this thread for discussion. I'd prefer to see bug reports in the Issues area of the Github repository, but it's not the end of the world if you post them here (or both).


REVISION HISTORY
2018-07-08: Version 1.2 has been released to the Vera Plugin Marketplace (expected available tomorrow), and the AltAppStore (immediately available). This version provides a new date/time condition to replace the old (which is now deprecated and will be removed at 1.5), which has more definitive control, and separates sunrise/sunset to its own condition (with offsets). It also adds a "test" configuration screen to manipulate the (apparent) current date/time so you can test these conditions more easily. A new Runtime state variable accumulates the total time a ReactorSensor has been tripped (resettable; use for tracking furnace fan runtime for filter replacement, for example). And adds the missing UI for arming/disarming the sensor, plus bug fixes and other minor changes (see the CHANGELOG as usual).

2018-07-02: Version 1.1 has been released to the Vera Plugin Marketplace and AltAppStore. This version has a lot of bug fixes (most minor, a couple significant), and two new features: "sequences light" (creating time-dependency between conditions), and a real-time status display so you can see the logic in action.

2018-06-24: Version 1.0 has been released to the AltAppStore and Vera Plugin Marketplace.

2018-06-17: alpha1 released to Vera Plugin Marketplace.
« Last Edit: July 08, 2018, 02:20:00 pm by rigpapa »
Author of Rachio, Deus Ex Machina II, Intesis WMP Gateway, SiteSensor, DelayLight, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3 sandbox.

Online parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2411
  • Karma: +33/-45
  • Life Moves Pretty Fast....
Re: New Plugin: Reactor
« Reply #1 on: June 16, 2018, 08:09:22 pm »
Hi @rigpapa

This sounds pretty interesting.

I hope you don?t mind, I have one quick questions and a comment to ask.

1) do you anticipate this being able to work on UI5 too?
2) it sounds like you are going to be taking the previous combination switch to a new level. https://apps.mios.com/plugin.php?id=2388

Offline rigpapa

  • Sr. Member
  • ****
  • Posts: 467
  • Karma: +66/-0
Re: New Plugin: Reactor
« Reply #2 on: June 16, 2018, 09:04:53 pm »
1) do you anticipate this being able to work on UI5 too?
2) it sounds like you are going to be taking the previous combination switch to a new level. https://apps.mios.com/plugin.php?id=2388

I'd have to downgrade my Vera3 to UI5 to get an environment I could work and test in, but I'd be happy to do that if there's enough interest. Shall I count you as vote #1? :)

If CombinationSwitch is an 80% solution for common logic problems, Reactor is my attempt to capture 80% of the 20% it leaves unhandled. The logic in Reactor is a bit more definitive, in my view: rather than a list of conditions that turn on the switch when n of them are met, Reactor offers true boolean AND/OR logic. CombinationSwitch seems to only support the device state values that are related to the device's published "event list" options (the same options you would find in the scene trigger configuration), but most devices have a lot more variables, and Reactor is able to react to all of them. Reactor also handles non-device conditions, like powerful date/time restrictions and house mode changes, and I will add more as the needs become apparent. And, one of the features I incorporated into version 1.0 of Reactor that I felt was very important, is that it be able to react natively to the duration of a condition. For example, trigger when it's night and the door has been open for more than 10 seconds, or turn off the light if the door has been closed for 30 minutes (and do that even if Vera reboots or Luup reloads during the timing period). If you have multiple CombinationSwitch's configured, each is a separate instance of the plugin and has a larger footprint in memory than Reactor's child devices. And CombinationSwitch hasn't seen an update in almost 4 years, so I'm not sure how much formal support it's getting or will get going forward.

And of course, anyone reading this would just say "why not use PLEG?" PLEG is an excellent tool, to be sure, and I would (and do) recommend it for users with complex automation needs. I've used it myself (I bought 4 licenses, if memory serves, but I don't use them today). But the learning curve is daunting for many users, and even the astute spend considerable time becoming proficient with it for anything even modestly complex. Over the years it has also become larger and more demanding of system resources, and as a consequence of its power, complexity, and flexibility, choices in how rules are written can have leave the user with unanticipated and undesirable performance consequences that are difficult for most end-users to diagnose. As the Vera firmware itself has expanded, many devices are left so constrained that firmware upgrades cannot be performed with PLEG installed. It is also, as far as I know, the only plugin in the (modern) ecosystem that we are asked to pay for--not that that is unjustified, as Richard's work is excellent and valuable, but I blame Vera for leaving their firmware/UI so deficient in this area for the average user that they actually have to pay somebody else to fix it. There is room, in my view, for something between the void that Vera themselves has left, and the incredible power of PLEG, and that is one of two reasons I created Reactor (which will always be free, by the way--you now have it in writing).
Author of Rachio, Deus Ex Machina II, Intesis WMP Gateway, SiteSensor, DelayLight, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3 sandbox.

Offline rigpapa

  • Sr. Member
  • ****
  • Posts: 467
  • Karma: +66/-0
Re: New Plugin: Reactor
« Reply #3 on: June 17, 2018, 10:37:31 am »
FWIW, Reactor is now available in the AltAppStore for users of ALTUI (Vera and openLuup). The only version available currently is the "stable" branch.
Author of Rachio, Deus Ex Machina II, Intesis WMP Gateway, SiteSensor, DelayLight, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3 sandbox.

Offline opel-oleg

  • Sr. Newbie
  • *
  • Posts: 21
  • Karma: +0/-0
Re: New Plugin: Reactor
« Reply #4 on: June 17, 2018, 06:09:58 pm »
Installed a couple of my VeraEdge. I'm happy. On one device, finally, my, strongly curve, AutoAway has earned. On the other, also non-standard control of several heaters in my summer house .....
Configuring the plugin is available even to a dumbass like me :)
I think this plugin, like your other development, will also be in demand. 8)
« Last Edit: June 17, 2018, 06:13:10 pm by opel-oleg »

Offline sm2117

  • Jr. Member
  • **
  • Posts: 65
  • Karma: +0/-1
Re: New Plugin: Reactor
« Reply #5 on: June 18, 2018, 01:52:31 am »
Really appreciate the work you put into DelayLight and I'm keen to try Reactor now as well. I'm not afraid of LUA but I'd still rather use something like this for certain tasks, and the fact you've considered performance the way you have is incredibly important to me as well.

Thanks again.

Offline rigpapa

  • Sr. Member
  • ****
  • Posts: 467
  • Karma: +66/-0
Re: New Plugin: Reactor
« Reply #6 on: June 25, 2018, 09:06:10 am »
Version 1.0 released, now available in the plugin marketplace and AltAppStore.
« Last Edit: June 25, 2018, 09:26:48 pm by rigpapa »
Author of Rachio, Deus Ex Machina II, Intesis WMP Gateway, SiteSensor, DelayLight, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3 sandbox.

Offline Quixote

  • Sr. Member
  • ****
  • Posts: 323
  • Karma: +10/-33
Re: New Plugin: Reactor
« Reply #7 on: June 25, 2018, 07:37:42 pm »
I have a feeling this will breathe new life into my Vera. I'll be installing this when I get back from my business trip.
Thanks!!!
My "Karma" has been modified by 2 or 3 douchebags that didn't like that I criticized the plugin that they worship. I'm not actually a bad person.

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3255
  • Karma: +191/-9
Re: New Plugin: Reactor
« Reply #8 on: June 25, 2018, 11:07:04 pm »
Awesome.  Now I can put Combination Switch to bed and recommend its successor.  Great work, rigpapa.

Offline Nameless

  • Full Member
  • ***
  • Posts: 163
  • Karma: +3/-0
Re: New Plugin: Reactor
« Reply #9 on: June 25, 2018, 11:33:42 pm »
Might be just me, but version 1.0 is leaving the Conditions section totally blank. I'm using a Fire tablet and have used Chrome and the Silk browser with the same result. I should mention that the Vera Plus UI is so buggy it switches devices on me anytime I try to view any Advanced tabs.

EDIT: I have the same issue using a Windows 10 tablet using Firefox.
« Last Edit: June 26, 2018, 12:10:13 am by Nameless »

Offline rigpapa

  • Sr. Member
  • ****
  • Posts: 467
  • Karma: +66/-0
Re: New Plugin: Reactor
« Reply #10 on: June 26, 2018, 07:52:34 am »
I deveoped on Chrome and Firefox for Windows 10 (desktop), and also tested with Chrome and Firefox on Android (Galaxy S2 Tab 7), all OK. I'll readily admit the JS is heavy, and my testing would  not exclude the possibilty of something in your Vera configuration taking or making a broken code path. Do you have a desktop and have you tried it there?
Author of Rachio, Deus Ex Machina II, Intesis WMP Gateway, SiteSensor, DelayLight, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3 sandbox.

Offline rigpapa

  • Sr. Member
  • ****
  • Posts: 467
  • Karma: +66/-0
Re: New Plugin: Reactor
« Reply #11 on: June 26, 2018, 08:53:27 am »
Might be just me, but version 1.0 is leaving the Conditions section totally blank. I'm using a Fire tablet and have used Chrome and the Silk browser with the same result. I should mention that the Vera Plus UI is so buggy it switches devices on me anytime I try to view any Advanced tabs.

EDIT: I have the same issue using a Windows 10 tablet using Firefox.

Wait... one more thing... are trying to manipulate the first sensor device that was created during the install of the plugin? Try this... create another sensor using the "Add Sensor" button in the parent/master device control panel. Then, try to edit the new Reactor Sensor and see if you get the same results.
Author of Rachio, Deus Ex Machina II, Intesis WMP Gateway, SiteSensor, DelayLight, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3 sandbox.

Offline Nameless

  • Full Member
  • ***
  • Posts: 163
  • Karma: +3/-0
Re: New Plugin: Reactor
« Reply #12 on: June 26, 2018, 01:31:51 pm »
So, I ended up removing the plugin last night because I couldn't even delete any of the sensors created. For whatever reason, this cured the issues I've been having where devices keep changing when moving to the Advanced tab. It was so bad last night I couldn't view any settings within any device without it showing the wrong device details.

Not saying your plugin is the cause of this mess. I suspect it to be a bigger issue with my Plus. I really like the layout of your plugin, so will be installing it again from a desktop. I'll then test what you suggested to see if that rights the ship.

Sent from my LGUS992 using Tapatalk


Offline rigpapa

  • Sr. Member
  • ****
  • Posts: 467
  • Karma: +66/-0
Re: New Plugin: Reactor
« Reply #13 on: June 26, 2018, 05:05:37 pm »
Not saying your plugin is the cause of this mess.

It may be. This plugin is particularly heavy on the JavaScript side, and last night I discovered something I was doing that may well be the cause (I've also observed this behavior, so I have a good environment to test with). When you re-install it, either (a) install from the "stable" branch on Github, or (b) install from the marketplace, but then go get the J_ReactorSensor_UI7.js file from the stable branch and upload that over the marketplace version.

Specifically, I was modifying (sorting alpha) the array of devices returned by the JavaScript API called api.getListOfDevices(). It turns out, that call gives you the UI's working copy directly (i.e. it returns a reference to it, not a clone of it), so modifying it yields... interesting... results in the UI after. Cloning the array on request seems to have fixed this on my development system. I did not notice any issue before or after this modification on ALTUI (which is to say only that I didn't notice; I'd have to ask amg0 about the semantics of that API call on ALTUI).
« Last Edit: June 26, 2018, 05:08:00 pm by rigpapa »
Author of Rachio, Deus Ex Machina II, Intesis WMP Gateway, SiteSensor, DelayLight, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3 sandbox.

Offline Nameless

  • Full Member
  • ***
  • Posts: 163
  • Karma: +3/-0
Re: New Plugin: Reactor
« Reply #14 on: June 30, 2018, 06:18:02 pm »
Not saying your plugin is the cause of this mess.

It may be. This plugin is particularly heavy on the JavaScript side, and last night I discovered something I was doing that may well be the cause (I've also observed this behavior, so I have a good environment to test with). When you re-install it, either (a) install from the "stable" branch on Github, or (b) install from the marketplace, but then go get the J_ReactorSensor_UI7.js file from the stable branch and upload that over the marketplace version.

Specifically, I was modifying (sorting alpha) the array of devices returned by the JavaScript API called api.getListOfDevices(). It turns out, that call gives you the UI's working copy directly (i.e. it returns a reference to it, not a clone of it), so modifying it yields... interesting... results in the UI after. Cloning the array on request seems to have fixed this on my development system. I did not notice any issue before or after this modification on ALTUI (which is to say only that I didn't notice; I'd have to ask amg0 about the semantics of that API call on ALTUI).


I went ahead and installed this using your (b) approach. This version seems much more stable with no issues of the icons changing or random device details appearing in the Advanced tabs.
I've ran a few tests today and am finding that the time/date triggers appear to be working well. Though, I am not having much luck checking humidity data from my thermostat, for some reason. It won't trip when my humidity is >=##. I'll do further testing with other devices and additional testing on my Honeywell thermostat to see if this is just for the humidity it reports.
Additionaly, I cannot get notifications to work when the sensor trips. I have email alerts setup with my Plus for a few things and those appear to be working. I may try to loop in an additional device, such as a virtual switch, to see if I can get notifcations to work in a round-a-bout way. When I get time to test this, I'll let you know my findings.
I appreciate your work on this. I've got some ideas of how I can use this in my automation system down the road.