Author Topic: Force turn on/off virtual switch  (Read 661 times)

Offline gabayarden

  • Newbie
  • *
  • Posts: 12
  • Karma: +2/-0
Force turn on/off virtual switch
« on: February 11, 2017, 03:48:05 am »
I am using virtual switch for triggering scences for example:
A virtual switch that represent the TV.
When I turn off the switch the tv will turned off by a scene and the same for turn on.
The problem is when the tv was turned off manually but the switch is in on mode. Now I cant turn on the switch because its already in turn on mode so I need to do it manualy or to turn off then turn on the switch.
Hope you understand  ???
How do I force turn off the virtual switch even if the switch is in off mode?

Offline gabayarden

  • Newbie
  • *
  • Posts: 12
  • Karma: +2/-0
Re: Force turn on/off virtual switch
« Reply #1 on: February 11, 2017, 07:53:45 am »
If any one will also face with this problem:
I added a new state to the virtual switch called "nothing"
then, in any mode switch (on/off) I am changing the switch to "nothing" and then I can switch it to ON or Off over and over again :)
Attached the new virtual switch files

Offline Martin79

  • Newbie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: Force turn on/off virtual switch
« Reply #2 on: February 17, 2017, 11:32:20 am »
Hi,
this would be a great feature. but i got a problem to install it. i opened the json, copy the code, go to develop apps/ device simulator json, and paste the code. then i get invalid json error. do i have to add something to the code, or do something else?

Thank you

Offline dpaik

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: Force turn on/off virtual switch
« Reply #3 on: February 20, 2017, 12:20:34 pm »
This works great!!! Thanks for writing this.

Offline Martin79

  • Newbie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: Force turn on/off virtual switch
« Reply #4 on: February 20, 2017, 06:05:43 pm »
ok, im really new with vera and i`m just a user without any knowledge in writing pc things, and it is not helpful that my mother tongue is another. could anyone tell me what to do please?
i opened the code on my mac, this happens with text edit, i`ve copied that and paste it into apps/ develop apps/ device simulator.
i get an error???  what am i doing wrong?
i would be very thankfully if anyone would take 2 minutes to explain me how to...

thank you for your time and best regards
martin

Offline Don Phillips

  • Hero Member
  • *****
  • Posts: 852
  • Karma: +18/-8
    • Worthington Engineering, Inc.
Re: Force turn on/off virtual switch
« Reply #5 on: February 20, 2017, 06:40:26 pm »
Download those 2 files and then upload them onto your Vera here:
Vera 3, UI7 1.7.947, CT101 t-stat, Everspring motion detector, GE/Jasco switch, Leviton outlet, AeonLabs door sensor, Insteon garage control, Blue Iris, Sricam SP011, iPhone locator, APCUPSD, VeraMate, VeraAlerts, PLEG, House Modes, Countdown Timer, DVR, Virtual & Multi Switch, Weather, Sys. Mon.

Offline dpaik

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: Force turn on/off virtual switch
« Reply #6 on: February 20, 2017, 07:00:34 pm »
Apps>Develop Apps>Luup Files> check "Restart Luup after upload"> then upload the two files

Offline Martin79

  • Newbie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: Force turn on/off virtual switch
« Reply #7 on: February 20, 2017, 07:32:06 pm »
this is working :-)
thank you very very much

Offline cgmartin

  • Newbie
  • *
  • Posts: 9
  • Karma: +2/-0
Re: Force turn on/off virtual switch
« Reply #8 on: October 17, 2017, 12:20:04 am »
Thanks for posting this. This has come in handy as a workaround for Alexa's use of scenes, where you are forced to say "Alexa, turn on {scene_name}" even when you actually want to turn "off" something, ie. "Alexa, turn on Downstairs off". I didn't like saying that.

By using this 3-state Virtual Switch I'm able to say "Alexa, turn [on|off] Downstairs" and it will always run those scenes in the background, regardless of what state the lights are in. I can control the individual lights separately ("turn off Kitchen"), and then go back to using the Virtual Device to turn all of Downstairs on or off.

Offline Broncswon

  • Sr. Newbie
  • *
  • Posts: 20
  • Karma: +0/-0
Re: Force turn on/off virtual switch
« Reply #9 on: October 20, 2017, 06:36:32 am »
Hmm, I've uploaded both files and I still only have on/off state?  Any ideas on steps to try and resolve this?  Would really like this functionality.

Offline jswim788

  • Hero Member
  • *****
  • Posts: 511
  • Karma: +25/-2
Re: Force turn on/off virtual switch
« Reply #10 on: October 20, 2017, 11:32:52 am »
Hmm, I've uploaded both files and I still only have on/off state?  Any ideas on steps to try and resolve this?  Would really like this functionality.
Note that these 2 files don't have the same name as the original implementation files.  You either need to rename them (overwriting the originals - removing the "_2" in them), or you need to go to the particular virtual switch you want to change and go to the advanced tab and change the implementation and device files to match these files.  Apologies if you've already done this - just wanted to point it out in case you overlooked this.