Author Topic: Combination Virtual switch plugin (UI5)  (Read 109435 times)

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3226
  • Karma: +180/-8
Combination Virtual switch plugin (UI5)
« on: June 26, 2012, 06:34:01 am »
I've put a plugin onto apps.mios.com that should remove the need for Luup programming for a whole range of common scenarios.

The Combination Switch looks like a binary light. Instead of you turning it on and off manually, the plugin watches the state of other devices on Vera. You set conditions ("This dimmer is between 10% and 70%", "That light is off"), and a threshold number. The plugin counts how many conditions are true, and when the count equals or exceeds the threshold, the Combination Switch turns on. When the count goes below the threshold, the Combination Switch turns off.

If you set the threshold to 1, you have the equivalent to a Boolean OR. If you set the threshold to the number of conditions, you have the equivalent to a Boolean AND. You can also use thresholds in between to get a kind of consensus sensing.

The Combination Switch fires events when the threshold is met and when it is lost. You can use these in notifications or you can use them as triggers for other scenes.

More in the following posts.
« Last Edit: April 26, 2014, 09:36:46 pm by futzle »

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3226
  • Karma: +180/-8
Re: Combination Virtual switch plugin (UI5)
« Reply #1 on: June 26, 2012, 06:35:48 am »
Here are the states that can be listed in a condition:

  • Switch Power Status: Tests binary switches (and things that pretend to be binary switches, including Combination Switches). Two options: true when the switch is on; true when the switch is off.
  • Dimmer Level: Tests dimmers (and things that pretend to be dimmers, like blinds). True when the dimmer level is in the range x to y inclusive.
  • Virtual Switch Status: Tests the Virtual Switch device from apps.mios.com. Two options: true when the switch is on; true when the switch is off.
  • Variable Container: Tests the Variable Container device from apps.mios.com. Tests one of the five variable slots for string equality to a supplied constant value.
  • Security Sensor: Tests any security sensor (door, motion, temp leak, smoke). Tests armed-or-bypassed, tripped-or-not-tripped, and combinations of the two.
  • Power Consumption: Tests any energy metering device that produces instantaneous power measurements. True when the power consumption is in range x to y inclusive. Negative power is allowed. Leave a box blank for an open-ended comparison (±∞).
  • Temperature: Tests any temperature sensor device. True when the temperature is in range x to y inclusive. Negative temperatures are allowed. Fractional temperatures, too, if your sensor can convince Vera to report it. Leave a box blank for an open-ended comparison (absolute zero, +∞).
  • Weather conditions: Tests the main device of the Google Weather plugin from apps.mios.com. True when the current weather condition matches the one selected.
  • Sun Position: Tests sun position as provided by the Heliotrope plugin from apps.mios.com. Can test altitude, azimuth, declination and right ascension.  True when the selected variable is in the range x to y inclusive. Azimuth and right ascension wrap around so you can refer to west as azimuth -90 or 270.
  • Door lock status: Tests any door lock. Tests door-is-locked, or door-is-unlocked.
  • Alarm partition armed status: Tests a partition of a security system.  Two options: true when partition is armed; true when partition is disarmed.  (For more detailed tests, see the next entry.)
  • Alarm partition detailed state: Tests a partition of a security system.  There are about a dozen states of armed-ness that can be tested, including ready-to-arm, entry/exit delay, stay/away mode. Not all states are supported by all brands of security system.
  • Humidity: Tests humidity sensors (physical and virtual). True when the humidity is in the range x to y inclusive.
  • Day or Night: Tests the state of devices using the Day or Night plugin from apps.mios.com.  True when this plugin reports day, or night.
Watch this space. More to come.
« Last Edit: June 22, 2013, 08:36:45 pm by futzle »

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3226
  • Karma: +180/-8
« Last Edit: December 23, 2012, 05:52:59 pm by futzle »

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3226
  • Karma: +180/-8
Scenario: Notification when switch status changes
« Reply #3 on: June 26, 2012, 07:09:29 am »
In this scenario, imagine that you have two energy-metering switches which you leave on all the time (one on a fridge and another on an aquarium heater). If the power to either one turns off, you need to be notified.
  • Create a Combination Switch. Rename it to All Switches On.
  • Go to the Configure tab. Add two conditions: Switch Power Status of Fridge is OnSwitch Power Status of Aquarium Heater is On. Set the Threshold to 2.
  • Go to the Notifications tab. Add a notification for Virtual Switch Status Changes > Switch turns off. Choose a user to notify.
« Last Edit: June 26, 2012, 07:59:12 am by futzle »

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3226
  • Karma: +180/-8
Scenario: Prevent events from firing when on vacation
« Reply #4 on: June 26, 2012, 07:50:05 am »
In this scenario, you have a light and motion sensor outside your front door. When not on vacation, you want motion to turn on the light. When on vacation, motion doesn't turn on the light. You are using a Virtual Switch called Vacation to indicate your vacation state.

  • Create a Combination Switch. Rename it to Motion Vacation Filter.
  • Go to the Configure tab, and add a condition Virtual Switch device Vacation is On.
  • Create a scene. Rename it to Unfiltered motion detection. Make the scene activate the Trigger Poke button on the Motion Vacation Filter. Add a trigger to the scene: An Armed Sensor is tripped.
  • Create a second scene. Rename it to Filtered motion detection. Make the scene turn on the light. Add a trigger to the scene: Device Motion Vacation Filter, event Triggered Poked while virtual switch is off.
« Last Edit: June 22, 2013, 08:37:36 pm by futzle »

Offline teonebello

  • Sr. Member
  • ****
  • Posts: 403
  • Karma: +0/-0
  • Macs, Home Automation, Bikers
Re: Combination Virtual switch plugin (UI5)
« Reply #5 on: June 26, 2012, 10:35:57 am »
I have installed the version 2 and I have the error 'Combination Switch: Startup Lua Faiiled'

Is it due to the bugged version 2?

Should the version 3 fix this problem?
I have a Vera 3 with 1.5.346.

Thank you

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3226
  • Karma: +180/-8
Re: Combination Virtual switch plugin (UI5)
« Reply #6 on: June 26, 2012, 05:17:56 pm »
I have installed the version 2 and I have the error 'Combination Switch: Startup Lua Faiiled'
Is it due to the bugged version 2?
Should the version 3 fix this problem?

Yes, and yes. Version 3 has been awaiting approval [edit] approved.

The bug in Version 2 can be avoided by ensuring that you have at least one of each of the four device types that the plugin monitors. You've probably already got a binary switch and dimmer, so create a dummy Virtual Switch and a dummy Variable Container.
« Last Edit: June 29, 2012, 06:59:09 am by futzle »

Offline davidd1205

  • Full Member
  • ***
  • Posts: 158
  • Karma: +0/-0
Re: Combination Virtual switch plugin (UI5)
« Reply #7 on: June 27, 2012, 10:18:58 am »
thanks for your plugin  ;)

i have a problem with my sensor sp103

i make a scene for my alarm and i would be like use your plugin for watch the status to my sp103
if tripped l'alarm don't turn on and notify me a door is open and it's ok my alrm turn on with my plugin calendar

it's possible to make a status tripped or not tripped ?

thanks

Offline chris66

  • Sr. Member
  • ****
  • Posts: 271
  • Karma: +9/-7
Re: Combination Virtual switch plugin (UI5)
« Reply #8 on: June 27, 2012, 12:30:49 pm »
@futzle, that kind of plugin should be integrated ASAP in the Vera Core application! Great!  ;)

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3226
  • Karma: +180/-8
Re: Combination Virtual switch plugin (UI5)
« Reply #9 on: June 27, 2012, 05:45:27 pm »
it's possible to make a status tripped or not tripped ?

Version 3 doesn't do this, but a future version will definitely have sensor conditions. Version 4 up has this support.
« Last Edit: August 19, 2012, 03:21:30 am by futzle »

Offline davidd1205

  • Full Member
  • ***
  • Posts: 158
  • Karma: +0/-0
Re: Combination Virtual switch plugin (UI5)
« Reply #10 on: June 28, 2012, 03:29:02 am »
it's possible to make a status tripped or not tripped ?

Version 3 doesn't do this, but a future version will definitely have sensor conditions.

thanks very cool job  ;)

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3226
  • Karma: +180/-8
Re: Combination Virtual switch plugin (UI5)
« Reply #11 on: June 28, 2012, 06:12:12 am »
Version 4 has been submitted with support for security sensors.

I suggest that you don't use the tripped/not tripped states for transient sensors like motion sensors. Such instantaneous events are better tied to the Trigger Poke button. Door sensors, of course, are a different beast.
« Last Edit: June 22, 2013, 08:38:04 pm by futzle »

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3226
  • Karma: +180/-8
Scenario: Evaporative cooling shutoff when too many windows closed
« Reply #12 on: June 28, 2012, 06:33:01 am »
In this scenario, imagine that you have an evaporative cooling system and several door/window sensors. Evaporative cooling works best when the doors/windows are left open, so you want the system to shut down when fewer than two door/windows are open.

  • Create a Combination Switch. Rename it Too many closed windows.
  • Go to the Configure tab and add one condition for each of your door/window sensors, with the test Not tripped while armed. Set the threshold to the number of doors/windows, minus 1.
  • Create a scene. Rename it Evaporative cooling shutoff. Add a trigger: Too many closed windows, condition Virtual Switch Status changes > Switch turns on. Make the scene turn off the evaporative cooling.

Bypass a sensor to pretend its door/window is open.

Tip: You can add the same condition twice, say, a big door that "counts" as two windows.

Offline davidd1205

  • Full Member
  • ***
  • Posts: 158
  • Karma: +0/-0
Re: Combination Virtual switch plugin (UI5)
« Reply #13 on: June 28, 2012, 10:04:27 am »
Version 4 has been submitted with support for security sensors.

I suggest that you don't use the tripped/not tripped states for transient sensors like motion sensors. Such instantaneous events are better tied to the Trigger button. Door sensors, of course, are a different beast.

a beta for version 4 is possible ?

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3226
  • Karma: +180/-8
Combination Virtual switch plugin (UI5)
« Reply #14 on: June 28, 2012, 04:28:27 pm »
a beta for version 4 is possible ?

That functionality for apps.mios.com is not yet present. For bleeding edge use, you can find the plugin at code.mios.com, browse the source, and download the files yourself. In Version 4, only the new file (obviously the one with SecuritySensor in its name) changed.

If that is too daunting, you will have to wait until an MCV staff member approves the new version.