Combination Virtual switch plugin (UI5)

You don’t need to assume, the power is in your hands to find out :slight_smile:

Let me know how the lock status file goes, if I got locked/unlocked the right way around, anything else you notice.

OK this isn’t rocket science but I’m having problems getting Combination Switch to trigger a scene.

I have 2 scenes Turn Air ON and Turn Air Off. I have Combination switch monitoring the security sensors on my doors and windows. (5 sensors) If any sensors are triggered I want to trigger Air Off. When they reset I want to trigger Air On. The scenes work when manually run. The Combination Switch “light” icon turns on and off as the sensors trigger it. But when I set the scene(s) to be triggered when the virtual switch is off (or on), nothing happens.

What am I missing?

jvilla,

One of two things is happening.

One is that the Combination Switch status change (off to on, or on to off) isn’t registering. To test for that, go to your Combination Switch’s Notifications tab and add a notification for Virtual Switch Status Changes. See if you get the notification when you walk around the room.

Two is that you’ve used the wrong event on the scene. Do use “virtual switch state changes”. Do not use “triggered while switch on” or “triggered while switch off”.

Failing that, I will need to make a version of the plugin with extra logging, and you will have to go trawling through the Luup logs.

futzle!!! :smiley:

WORKED FIRST TIME!

Love the plug-in architecture! This literally allows me to create an smart auto-lock scheme without code!!!

Now someone needs to make a plug-in that does all this in one. :wink:

[size=18pt]How to make your z-wave lock smart so it doesn’t auto-lock when it’s open:
[/size]
Here’s the method:

[ul][li]Existing Devices: Door Lock, Door Sensor[/li]
[li]Device: Door State CLOSED/UNLOCKED
[size=8pt]Create the Combination Switch for the door’s ‘auto-lock’ state. When door is closed, AND unlocked, the state is ON.[/size][/li]
[li]Device: Door Autolock Timer
[size=8pt]Create a countdown timer. The timer completing is used as the trigger for securing the door. [/size][/li]
[li]Scene: Door: SECURE
[size=8pt]This scene is simple and useful for locking the door. You could go as far as wiring up more Combination Switches to trigger locking the door only when it’s closed. I’ve still got some luup code here that prevents the door from locking if it’s open. Neither is necessary for this example.[/size][/li]
[li]Scene: :hourglass: Door Autolock Start
size=8ptStarts the timer. Triggered by the Door State CLOSED/UNLOCKED Combination Switch turning ON.[/size][/li]
[li]Scene: :hourglass: Door Autolock Cancel
[size=8pt]Cancels the timer. Triggered by the Door State CLOSED/UNLOCKED Combination Switch turning OFF.[/size][/li][/ul]

That’s it! I have mine set to two minutes. 8)

Just to wrap up the cool factor:
I just removed almost all of my luup code. :slight_smile:
The only thing left is a simple scene luup that blocks a condition for locking the door. I may eventually remove that as well. :slight_smile:
But there are lighting scenes that had code. All replaced by combination switches.
And as I got used to how they worked, it got easier and cleaner. :slight_smile:

I’ve submitted version 11, with door locks, to apps.mios.com.

I think this is my issue. I don’t understand why triggered while switch is on/off won’t work? If I just use state change, I won’t be able to tell for sure if the switch is on or off.

@jvilla:

This took me a second to understand. This is why it’s a “Combination SWITCH”.

The trigger effectively amplifies it’s usefulness… :slight_smile:

Yes, there is an event for changes in state, but you can also wire up to ‘trigger’ the switch.

Here’s my example I use today:

  • I have the Heliotrope plugin. I wired up a ComboSwitch to determine if it’s ‘night’ time (aka light or dark). Name: “Is Night?”
  • I have a ComboSwitch that then tells me if the state of the lights in my house is bright enough. >=40% entry light, OR >=30% living room lights. Name: “Is Enough Light?”
  • Then another ComboSwitch that is ON when “Is Night?” is ON, AND “Is Enough Light?” is OFF. Name: “Needs Auto Light?”
  • I then have a scene that will set the entry light to 40% and it is triggered by the previous ComboSwitch(“Needs Auto Light?”) when it’s triggered while ON.

I can then test this by clicking ‘Trigger’ on the “Needs Auto Light?” device and depending on whether it’s night time and there’s not enough light, it will raise the entry light to 40%.

  • Next I create a scene that will click ‘Trigger’ on that device when I enter my code in my door lock. :slight_smile:

Cool stuff. Works like a charm. The ‘Trigger’ is the key to it working without an insane amount of other virtual devices or extra code.

Edit 2013-06-23: Revisionism ahead. The “Trigger” button has been renamed “Poke” from version 15 onwards, to prevent this kind of confusion.

You can use the Combination Switch two ways. One is to use it as a straight condition-tester. You configure the conditions and ignore that big “Trigger” “Poke” button on the device’s dashboard. The Combination Switch turns on or off, and you catch the state changes with the “Virtual Switch Status Changes” event. For most cases, this is good enough.

The other way to use the Combination Switch is to use it as an enabler when some instantaneous event (such as a motion sensor tripping) comes along. If the event happens and the conditions are not right, you want to filter the event out and ignore it. Otherwise, you want the Combination Switch to pass the event on to activate some scene. In this case, you make the instantaneous event push the Combination Switch’s “Trigger” “Poke” button, and have all the other, enabling, conditions in the Combination Switch’s configuration as before. You don’t care about the conditions until the instantaneous event Triggers the Combination Switch. Catch the event with “Triggered Poked while virtual Switch is On” or “Triggered Poked while Virtual Switch is off”, and feed it through to a scene that does its business.

TL;DR version: use “Virtual switch status changes”, unless you’ve got something pressing the Combination Switch’s “Trigger” “Poke” button.

(I admit that “Trigger” is not a great name for this feature since the term is already used elsewhere in the MiOS UI. Any better suggestions, people? I thought about something whimsical like “Prod” but who wants a bunch of “Prod” buttons over their dashboard?)

If I just use state change, I won't be able to tell for sure if the switch is on or off.

I get what you’re saying, but why do you need to know if the switch is (still) on or off? What would Vera do, that it hadn’t already done at the state change? Turn the air conditioning on (or off) again? It’s already in that state, or should be. The Combination Switch tracks the state pretty well and it should notice a change even if it happened in the middle of a Luup engine crash.

If you’ve got some critical piece of equipment that is safe to send redundant on/off commands to, and you want to have Vera check every five minutes Just To Be Sure, you can tie a Schedule to a scene, and make the schedule press the Combination Switch’s “Trigger” “Poke” button every five minutes. Then you’d be in Event Enabler territory and you’d be using the “Triggered Poked while virtual switch on/off” events to fire your on/off scenes.

beautiful plugin.

How do I get more than one combination switch installed? I installed from the app store, but I need more for other purposes… Am I missing something?

[quote=“Intrepid, post:90, topic:171904”]beautiful plugin.

How do I get more than one combination switch installed? I installed from the app store, but I need more for other purposes… Am I missing something?[/quote]

This is one I CAN answer. Go to the apps and click on the combination switch. You will see the switch you have already installed. Underneath that will be a “Create Another” button click that and save and it will magically appear. Pretty cool… huh!

J

[quote=“jvilla, post:91, topic:171904”][quote=“Intrepid, post:90, topic:171904”]beautiful plugin.

How do I get more than one combination switch installed? I installed from the app store, but I need more for other purposes… Am I missing something?[/quote]

This is one I CAN answer. Go to the apps and click on the combination switch. You will see the switch you have already installed. Underneath that will be a “Create Another” button click that and save and it will magically appear. Pretty cool… huh!

J[/quote]

Ahh, I see it. I just upgraded to UI5. This is much easier than it was in UI4.

Futzle, I must say this is one of the most useful, well thought out add-ons for vera I have seen since I started. Great job. And thank you.

[quote=“futzle, post:74, topic:171904”][quote=“thetwc, post:71, topic:171904”]I added 4 conditions:
[…]
Looking at it again now, all 4 conditions are met. The light bulb on the CS is on, but it has not triggered the scene to switch the heater on.[/quote]

The event is thrown only when the combination switch moves from off to on. Did that happen? If it’s on the whole time then no event will fire.

If you can see the combination switch change from off to on, and the event still isn’t firing, can you SSH to the Vera and grab the /var/log/cmh/LuaUPnP.log contents for a second or two around the change? That’ll help me to pinpoint the bug very quickly. Let me add some more debug code to the plugin so you can send me a useful Luup log.

Edit: this (attached) is the closest that I can get to your description with the devices in my house. With these devices, It Works For Me[sup]TM[/sup]. So unless there is something different about your devices…?[/quote]

Not only a great plugin, but great support too. Thank you for all of this.

I think I was doing it wrong but now I understand when it throws the scene execute makes a lot more sense.

I made it more complicated as my heater on for given conditions scene has a delay in the same scene such that it then turns off after 20mins if the trigger hasnt fired again. So if the motion detector remins tripped, the CS remains on, but the event countdown has already started.
I’ll try it with triggered while on.

Thank you.

+1 on the great support for this very valuable add in (as I read all these posts), this is phenomenally helpful.

Two suggestions for values it would be nice to be able to add in there would be humidity (As reported by the google weather plugin) and time or time range of day. Like “if it’s after 7am and the humidity is above 65%. . .” Or maybe (noob alert) I’m putting functions of a trigger and functions of a schedule together into one idea?

Thx!

Glad you’re all liking the plugin.

I’ve already talked about why I can’t do time-of-day with the Combination Switch plugin (there isn’t a variable with a time-of-day state that the plugin can watch). Humidity should be a doddle though; just a renaming of the dimmer level one with some changed strings. I’ll add it to the pile. (mcvflorin is taking a vacation so there won’t be any updates to plugins for a couple of weeks.)

@The Ace: use the heliotrope plugin instead of time of day. Probably better for most cases since anything dealing with the weather is tied to the sun.

@Futzle: why not make a time of day plugin? :slight_smile:

@Futzle:
Things to add to the combination switch:
Timer: Is Running
Timer: Is Muted

@Futzle,
I hope you have given this one more consideration? You can see there is a lot of use that would come from my feature request to integrate sunset/sunrise/dusk/dawn settings into the Heliotrope plugin.

[quote=“electricessence, post:97, topic:171904”]@The Ace: use the heliotrope plugin instead of time of day. Probably better for most cases since anything dealing with the weather is tied to the sun.

@Futzle: why not make a time of day plugin? :)[/quote]

@Aaron:
I agree with both of you.

Having those triggers or states is nice for scripting, but it forces non-configurable specifics. Because someone in Alaska may want a different offset than what someone in Hawaii wants. So it’s better to create other devices that detect these states.