Trying to get a handle virtual switches?

Trying to get a handle virtual switches?

What are they used for?

In their simplest form, do they control devices, or vice versa, or both?

From reading threads, my understanding is that they can toggle a device (on/off). Using UI7 (only), how do I go about doing so to toggle one device? It seems I create one VS, then one scene. For the scene, is it device?, schedule?, manual?, then what? Do I include code or use the Advanced editor in the scene?

There are threads that discuss the topic, but many are years old and may or may not be accurate.

P2epr#

They are often used to control Automation logic.
i.e. a) Turning then on can start some automation logic
b) There setting can control behavior, before house modes in UI7 virtual switches were used to indicate things like
Nighttime, or AWAY … and then the automation logic would operate based on the state of the virtual switches and the real devices in your home.
I still use Virtual switches AND NOT HOUSE modes … because for I can have both NIGHT and AWAY active.
3) They are used as User Interface components that the automation sets/clears … By looking at the virtual switches … you can see what your automation logic is doing.

With Voice control knowing about Switches (including Virtual Switches) you can control your automation logic the same as controlling a real device.

As an example of the third item, I have virtual switches for the 2 iPhones, called Don or Thea Home, which display on VeraMate only when on. I have a No One Home VS that is displayed only when on. And a Cameras Armed VS, and an Exterior Lights On VS, etc. Below is an example of the information at my finger tips:

Then a VS has supporting code? Where is it entered? I do not find a place other than in a scene that uses a VS.

I am not sure what you mean by supporting code.

You can use a VS as a trigger in a scene, or to set the VS as part of a scene. I use PLEG to set the VS’s and not as triggers. Within those scenes, you can write some LUA code to do what you need.

For instance, here is my PLEG status report which is triggered by House Modes. When House Mode is set to anything except Home (by another PLEG instance) It will execute a Cameras Armed action which includes LUA to “arm” Blue Iris (and arm the virtual motion sensors of my 4 cameras) and turn on the Cameras Armed VS so I can see on VeraMate cameras are armed. When back to Home Mode, the Disarm Cameras action runs, sending using LUA to “disarm” Blue Iris, and turns off the Cameras Armed VS. In VeraMate, thje Cameras Armed VS only displays when on so it disappears.

I created a simple PLEG device so that a VS would indicate the status of a light. Light on = VS ?on?, and vice versa. I currently control the light through its logical or physical device. The VS does change state, but only when the goes from off to on. Something is incorrect?

I understand the ?virtual? concept ? use it all the time with virtual machine (Hyper-V), but the implementation with Vera is escaping me.

On related items, when is a PLEG device saved ? as changes made, or when the edit dialog box is closed? Also, I saved the PLEG logic report by saving the page as .htm, opening that with MS Word, and then saving as a PDF. Is there a more direct method to create a PDF? I?m using Firefox.

Another example:

I use Combination switches as “IF … AND …” sentences for my scenes, and with some of my state logic there can be more than one combination that is valid while a scene is executing. To avoid scenes triggering in a landslide, i have VS’es that I turn off at the start of a scene, and on when i’m done. This avoids other scenes triggering while a scene is working.

Or, for example in geofencing: let’s say you want the scene to run when you pass some location but only in one direction (i.e. going from A to B, but not the other way. If you set a simple geofence, it ignores your direction, only location is important.
The easiest way is to set two geofences, one after another, and define that if you go through it, it sets virtual switch on. Then on the second scene you add additional condition to check the virtual switch status and run only if it is ON.
This way if you go from A to B you first go to location 1 (VS ON) then to location 2 (run if VS is ON). If you go the other way, you enter location 2 first, scene checks VS switch and see it is OFF, so it is aborted.

Without VS switch (something which keeps data about additional condition) this is hard to achieve.

Another example:

I do use the home modes so the house will do certain things when switching from to home. It doesnt matter why it switched. So I was having things happen when it went from Night to home as well as from away to home. I also may want different things to happen when my wife gets home than when I do.

I set up a VS for my status and one for my wife’s. When I am home it is on when I am not it is off, same for her’s. The really nice thing is, even if the house is in home mode, “My coming home” scene will still run when I pull in, so the driveway lights on my side turn on, etc. My wife will also check my switch status if she has to leave early to see if I have left work work yet. I have now set up one for my office and she can see if I am at the office or not. I work all over the place some days and sometimes she has trouble keeping track of the days Im in the office vs. being halfway across the state.

I have a VS that I filp that controls a group of things at once. the outside lights for example are all controlled by a scene that follows the VS position. I have many scenes that could include turning on those lights. Rather than having to edit all of them when I add another exterior light, I just edit the ones controlled by the virtual switch. It then get turned on or off with the rest by any scene already manipulating that switch.

I have a VS that I turn on when my parents come in town that overrides a bunch of logic in the house. They thought my house was broken.

We use iPhone Locator in VeraMate to see where each other are within 5 minutes (iPhone only refreshed or pings the phones every 5 minutes). This came in handy on MLK day (I was off so I cooked dinner). As I am waiting to place something in the oven and tracking her progress home from work, I noticed she is at the mailbox (we live in a condo) for a very long time. It was snowing very hard and after about 5 minutes of seeing her at the mailbox (I was manually refreshing iPhone Locator every few seconds), I started to get my gloves, coat, and shoes on to leave to walk to the mailbox to se what is up. As I leave the garage, I see her walking up the drive. Car got stuck in the snow.

All excellent ideas, but implementation is where I am hung up on.

is an idea that I?ve had. Not lazy here, but I need a hand in implementation.

Fist you set up the virtual switch. It is up to you if you toggle its position manually or by the scene.

Virtual Switch is not connected to any device (imagine a relay switch not connected to any wires), so when you toggle it, it is only status that changes.
So, to make it work you have to create a scene triggered by the switch status. If I understood @Priests comment correctly, he has a scene which turns the lights on if the VS status is ON and turns them off when VS status is OFF.

As I said, the way you control VS is up to you - you can toggle it manually or set up a scene. The trick is that every time you change the status of your VS, a follow up scene is executed.

Another way (VS as additional condition) needs some lua coding or PLEG.
This way you trigger a scene other way (i.e. motion sensor), but after the scene is triggered, it checks the status of your VS and acts accordingly (like: if VS is ON, then… else …)

[quote=“kwieto, post:12, topic:198386”]Fist you set up the virtual switch. It is up to you if you toggle its position manually or by the scene.

Virtual Switch is not connected to any device (imagine a relay switch not connected to any wires), so when you toggle it, it is only status that changes.
So, to make it work you have to create a scene triggered by the switch status. If I understood @Priests comment correctly, he has a scene which turns the lights on if the VS status is ON and turns them off when VS status is OFF.[/quote]
I set up a VS. Then I setup two scenes: one to turn on three devices, another to turn off the same three devices. In both scenes, the device trigger is the VS either on or off. By toggling the VS, the three devices change state. Ok, got that one, unless there is a different method to implement. Another question though: if I turn on one device manually (physically or via its logical device), then use the VS off, why does not the one device turn off? Seems to me that the off scene would set all targets to off.

Scenes mainly ignore devices’ states, so the command is sent to all devices. For those which are already off it will just have no effect.
So the conclusion is that something is wrong within the scene, or with the trigger.

Just for clarification: what state had virtual switch when you pressed “off”?
If the scenes worked as you described I assume that if your devices was set to off by virtual switch before, it was in the “off” state already?
If yes, then pressing it OFF will not work, as scene is triggered when device’s status is changed, and pressing OFF device which is already OFF doesn’t change anything.

This is the only explanation which I can imagine in this case, as the scene is really simple (turn devices off by trigger) and shouldn’t make any problems.

If the device you turned on does not have instant status (where it sends information to Vera to tell her something happened manually) then you have to wait until the device is polled in some way. Until Vera knows the device was turned on, it wont send a command to turn it off. Vera used to blast the command no matter what. Over time they have adjusted some of how it works and if she thinks a device is in one state and you command it to that state, it will not send the command since in her opinion, it would be a wasted use of resources. All of this is from my observations and I dont have a Vera engineer to back me up, but it is 100% the case in my house.

I dont have any devices that support instant status…but the majority of them still report their state back to Vera pretty quickly. For testing purposes, do the following:

Open the web page in your browser
go to devices
scroll to the device you are playing with manually
manually flip the switch and see how long it takes for very to show the change in status
once she shows the change, then flip your virtual switch and see if it hits that device

if you play with it voer and over again you will see what I mean. Until I had a very full and robust network of devices, nothing reported quickly. Now, everything does MOST of the time.

If a scene only has a VS as a trigger, then the devices will not trigger a scene. Scenes allow multiple triggers so you could add the 3 switches as triggers so any of the 4 triggers will execute the scene.

After further testing, the VS does work. Sometimes there is a ~10 second delay.
The steps:

  1. VS is off
  2. All devices in scene are off
  3. Turn on one device in scene
  4. Turn off VS
  5. Result is the device from #3 is turned off.

Thanks for the ideas!

Greetings,

Like OP, i struggle to wrap my head around how to setup and use Virtual Switches, despite reading a bunch of posts.

I have been interested in having Imperihome do something it doesn’t have built-in which is to go back to page after a set time when it’s on any other page.

I can have Imperihome go to a camera page when the ring doorbell at my front door detects motion but after that, it just stays on that page. I need something else to happen after that so i can tell Imperihone (via scene) to go back to the main page.

I know that with some effort it can be done with Tasker but i’m looking for a solution that is much less involved.

So that got me to thinking about possibly a virtual switch.

From reading above, i now understand that a VS changes “status”

so for example, if i can change it’s status to “ON” as part of the “motion at front door” scene then after a set time change it’s status to “OFF” and use that in a scene to make IH go to the main page - that would work perfect - provided…

  1. A VS can be made to change status after a period of time.
  2. The change in status can be used in a scene.

Is there any possibility to do what i want with a VS or am i way out in left field! :smiley:

That’s exactly what Virtual Switches are for … they are for automation.
You will likely find it better to use PLEG than a collection of scenes.

[quote=“treetop777, post:18, topic:198386”]so for example, if i can change it’s status to “ON” as part of the “motion at front door” scene then after a set time change it’s status to “OFF” and use that in a scene to make IH go to the main page - that would work perfect - provided…

  1. A VS can be made to change status after a period of time.
  2. The change in status can be used in a scene.

Is there any possibility to do what i want with a VS or am i way out in left field! :D[/quote]

Here?s a possible solution. I don?t have a motion sensor, so I used an off/on device (device controlling a light). PLEG report attached.

If the light is turned on, the virtual switch will indicate the new state. After a 30 second delay, the VS is turned off, but the light itself does not turn off.

Using the VS in a scene as you desire might cause a problem because the VS will be on, and then off. A better solution might be to turn off a second VS and use that in a scene. Not sure on this…

(Note that in the report under Actions it states Immediate - 1; Delay 30 ? 1, which I interpret to mean turn on immediately, wait thirty seconds and then turn on. But under Delay 30 it states newTargetValue=0. Also, the off portions of the PLEG are not needed, but a leftover from a different PLEG experiment.)