Pre-release: Combination Virtual switch plugin

Here’s a plugin that I’ve been working on for the last couple of weeks. It’s very raw at the moment, so I recommend only experienced plugger-innerers venture forth for the moment. UI5 only.

This plugin presents itself as a binary light virtual switch. Instead of you setting in on/off, the plugin watches the states of other devices on your Vera. When a certain number of devices meet their specified criteria, the plugin turns “on”. It turns “off” again when the number of devices meeting criteria drops below the threshold. Events fire when these happen, so the threshold-crossing is scene-able.

The “Trigger” button is for scene programming. It fires an event when the button is pressed and the threshold is met, or a different event when the button is pressed while the threshold is not met.

Right now it can watch only: binary switch status (on or off); Dimmer level in range x to y; Variable Container string equality.

I’ll be adding: Sensor armed; sensor tripped; temperature compared to temperature; temperature compared to setpoint; temperature in range; light sensor in range; Weather Plugin states; partition arm status; power compared with constant; power compared with power; Heliotrope altitude in range. Probably others. It’s readily extensible to do any other comparison for those who can program.

Obviously the main purpose of this plugin is to provide users with “AND” scene logic while staying away from Luup coding, but you might be thinking of another use for it. I’d love to hear people’s opinions and feature requests.

Edit: dimmer status; refactoring of code to make adding plugin-plugins easier.
Edit: more refactoring; variable container (as a gratuitous test of the extensibility of the API).
Edit: extended API to let conditions do more fancy JavaScript for configuration.

Futzle,

Great work. Does this show up correctly under my App? Let me know if support needs to be added.

  • Garrett

Great idea! I imagine it will reduce the need for LUUP coding, and maybe reduce scenes clutter (combining several scenes into one). Just a quick suggestion: maybe a 0 value in the “switch is on when” field means that ALL conditions must be met.

That dimmer range just saved me a TON of Startup Lua code… Can you allow for more than one dimmer to be included? So if ANY Device in this group; 23,44,43,65,76, has a dimmer range set between 85 and 100% then drop the respective dimmer to 84%?

Maybe that’s another beast in itself, but it sounds like i’ll at LEAST be able to do one dimmer per plugin…

Great work, going to implement this one ASAP.

Thanks

This looks really (really really) good !

Since getting my Vera, and not being a programmer, I’ve been determined to see what I can do via the UI. (I have enough trouble with English, let alone learning another language :wink:

As you planned, adding sensors and dimmers to this would be great, plus if you’re up for another idea, if you were to add an optional time options to the settings list, such as "is it (before or arfter) x hr x mins " then it sounds like you would meet my house ‘wake up’ and ‘sleep’ profiling requirement :wink: in one dashboard device.

It could be a game changer, if i have understood the potential correctly, especially when i think about some of the ideas I have for complex situations - so to do it in a simple way would be my dream :wink:

It didn’t, but I added code to set category_num to 3, so it will hopefully appear as a switch now (with useless on/off buttons). Edit: yep, it does.

I want to reserve 0 for when the user wants to keep the virtual switch on all the time (also I am thinking about a generic weighting system where it’s not just 0 or 1 for each condition). But I concede your point that “All” conditions is common enough that it should be selectable without having to type a number. Expanding the bottom part of the dialog into a radio group (“exactly n”/“at least n”/“all”) would do this.

Hmm, tricky. The Combination Switch can definitely watch five dimmers with a threshold of 1. Picking the victim device is, I think, going to be unreliable with the way I watch state variables. I’ll have to dwell on this one. Thanks for the outside-the-box idea!

Time, I thought that would come up. On one level it’s hard because the plugin works by running luup.variable_watch() statements, and time isn’t a state variable on any device. But time is very attractive in the boolean context, I agree.

One thing that will definitely work is to make a separate virtual switch device, attach scene schedules to the virtual switch to turn in on/off at defined times. The Combination Switch can* watch that virtual switch’s state.

  • Note hidden future tense.

New version today that watches dimmer level. Enjoy!

New version that adds support for @chixxi’s excellent Variable Container plugin. Took about 15 minutes to alter one of the other support files, which hopefully vindicates my architecture. :slight_smile:

Wow…
Excellent work Fuzle!
Thanks!

Can you include Timers also? I believe this is the most powerful plugin yet… Great work

I can only include variables that you can see Below the Line in the Advanced tab of a device. This includes things like switch status and temperature and other values that Just Are. It’s a limitation of the luup.variable_watch() function that forms the backbone of the plugin.

Timers don’t (as shipped) fall into that category, so the Combination Switch plugin can’t be informed when a timer changes. But it’s possible to cheat, with a second plugin that can turn a timer into a state variable. My Countdown Timer plugin does that, so you can be sure I’ll be adding support for that. Or you can do the Virtual Switch + Schedule method I mention above, to turn a time-of-day into a switch status.

Once I’ve cemented the plugin API I’ll release this plugin properly on apps.mios.com and post some examples of how to use time in a Combination Switch.

Oh, before I forget, Acknowledgments: Chris, for the obvious internal relationship this plugin has to dataMine. mcvflorin, for the ideas I snaffled from the Home Care plugin. TimAlls, for sharing his own specialized AND plugin with me and inspiring me to get off my butt and make this plugin. I’ll add to this list as my memory reveals other godparents to the plugin.

I’ll install the plugin and see what I can do to add support in a future version of my app that will require 1.5.372 or newer to function with 3rd party plugin support.

  • Garrett

I didn’t understand its function until I checked the screen shots; it’s not actually looking for a ‘certain number of devices’; it’s actually looking at specific devices, right? So it’s not ON when 4 devices are on; it’s ON when the coffee machine is off, the electric blanket is on, the bedside lamp is in a defined dim range, etc… right?

That is my understanding of the plugin. The switch will show as on once the criteria that you specified has been met.

  • Garrett
Oh, before I forget, Acknowledgments: Chris, for the obvious internal relationship this plugin has to dataMine. mcvflorin, for the ideas I snaffled from the Home Care plugin. TimAlls, for sharing his own specialized AND plugin with me and inspiring me to get off my butt and make this plugin. I'll add to this list as my memory reveals other godparents to the plugin.
Thanks for pressing on with this concept. Users who don't want to learn coding will really benefit! On my rough plugin I had a countdown timer as well as "if it's between time A and time B"....I like your concept, it is very simple. The feature request will be piling up soon! Have fun. ;D Regards Tim Alls

I have failed as a tech writer!

But seriously, Garrett’s description is right. You configure the conditions, choosing from the devices that you have, and the plugin counts the conditions that are true statements. Less than threshold = off. At or greater = on.

(Show of hands: who knows what the word “predicate” means? Too technical, even though it’s the exact right term?)

(Show of hands: who knows what the word "predicate" means? Too technical, even though it's the exact right term?)
[url=http://www.exchange3d.com/images/uploads/aff4578/Hands/Hands_1.jpg]8)[/url]

Ohhhh… no, I don’t think you did. I re-read, and with a better understanding of what this does, I think it makes perfect sense. Very cool.

Feature requests? :slight_smile:
I’m sure these options will be handy;
temperature range,
Time of day range
Heliotrope range
Light level range from sensor

Just to name a few…

Again, great work, setup a donate button, I’ll gladly buy you a few beers!

Sent from my SPH-D710 using Tapatalk 2

Great suggestions, keep them coming. I’m updating the first message in this topic with the list of conditions that I will be adding. I’m pretty sure that they can all be done within the existing framework, so I’ll go ahead and put it onto apps.mios.com real soon.

[quote=“big517, post:18, topic:171748”]Feature requests? :slight_smile:
I’m sure these options will be handy;
temperature range,
Time of day range
[/quote]
What he said, on these two… keeping in mind those that have >1 thermostat.