We have moved at community.getvera.com

Author Topic: vacation indicator for scenes  (Read 3523 times)

Offline Piwtorak

  • Hero Member
  • *****
  • Posts: 988
  • Karma: +4/-0
vacation indicator for scenes
« on: May 20, 2013, 05:02:50 pm »
Hello folks,...

is my first long trip using vera3 and occurs me the need to say for my daily scenes I am out !! (in Miami ) :)

I think in create a switch to turn on and put luup code to test in all my dailiy scenes...if that switch is on then do not run the scene. this if will be putted in the head of each scene.

someone can help me if I am right and pointing me to right direction ?

thanks in advance !
Vera3 (1), Airport Extreme (2), Apple TV (3), Sqblaster (1), GE Switch (3), GE Dimmer (1), Leviton VRCSZ2 (2), GE 45601 (1), Intermatic HA03 (2), GE Zwave Outlet (1), Remote Control Curtain (1) and growing.

Offline Z-Waver

  • Master Member
  • *******
  • Posts: 4437
  • Karma: +249/-120
Re: vacation indicator for scenes
« Reply #1 on: May 20, 2013, 06:51:17 pm »
If I ever got a vacation, I would have thought of this previously.
I'm hoping someone has a better plan than I do. But, I'm thinking that this will need a virtual switch, "On Vacation / Working Like A Dog" and then a bit of Luup code in each scene(pain) to test if the virtual switch is set to On Vacation.

Untested, let me know if it fails.
Code: [Select]
local ID_VSWITCH = 55

local VSWITCH = "urn:upnp-org:serviceId:VSwitch1"
local VacationMode = luup.variable_get(VSWITCH, "Status", ID_VSWITCH)

 if (VacationMode == "1") then
     return true
  else
     return false
  end

Offline Piwtorak

  • Hero Member
  • *****
  • Posts: 988
  • Karma: +4/-0
Re: vacation indicator for scenes
« Reply #2 on: May 20, 2013, 10:50:24 pm »
Great z-waver...

Happy in read your words.

But if this piece of code will stay in a txt document to paste in each new scene and in all old, I think the logic must be inverted if vacation is ON (1) return false.
The values for status are 0 (off) and 1 (on) ?

Thanks for think with me... Help a lot.
Vera3 (1), Airport Extreme (2), Apple TV (3), Sqblaster (1), GE Switch (3), GE Dimmer (1), Leviton VRCSZ2 (2), GE 45601 (1), Intermatic HA03 (2), GE Zwave Outlet (1), Remote Control Curtain (1) and growing.

Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: vacation indicator for scenes
« Reply #3 on: May 21, 2013, 05:02:43 am »
Quote
But if this piece of code will stay in a txt document to paste in each new scene and in all old...

Yes, if you want to put it in lots of places, you want it to be as simple as possible. 
You could get away with just writing:

Code: [Select]
return not vacationMode()
...if you wrap the code that Z-Waver gave into a function and put it into your Startup Lua:

Code: [Select]
function vacationMode ()
    local ID_VSWITCH = 55
    local VSWITCH = "urn:upnp-org:serviceId:VSwitch1"
    return luup.variable_get(VSWITCH, "Status", ID_VSWITCH) == "1"
end

To make that even easier, you could use the VSwitch utility routines described here:
http://forum.micasaverde.com/index.php/topic,14896.msg113156.html#msg113156
and then you never have to bother about finding the device ID, or spelling the serviceID correctly.

Just access the Virtual Switch by name:

Code: [Select]
return not (VSwitch.get("Vacation Mode") == "1")
Less is more.

------
Edit: added the == "1" which was missing in the last code snippet.
« Last Edit: May 22, 2013, 07:19:28 am by akbooer »
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline Z-Waver

  • Master Member
  • *******
  • Posts: 4437
  • Karma: +249/-120
Re: vacation indicator for scenes
« Reply #4 on: May 21, 2013, 08:47:27 am »
Snazzy!

I knew someone would do a better job than I.

Offline Piwtorak

  • Hero Member
  • *****
  • Posts: 988
  • Karma: +4/-0
Re: vacation indicator for scenes
« Reply #5 on: May 21, 2013, 10:33:42 am »
Fantastic !

one thing more...
how can I edit startup lua with security ?

thanks a lot !
Vera3 (1), Airport Extreme (2), Apple TV (3), Sqblaster (1), GE Switch (3), GE Dimmer (1), Leviton VRCSZ2 (2), GE 45601 (1), Intermatic HA03 (2), GE Zwave Outlet (1), Remote Control Curtain (1) and growing.

Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: vacation indicator for scenes
« Reply #6 on: May 21, 2013, 12:30:03 pm »
one thing more...
how can I edit startup lua with security ?

Not sure I quite understand the question...

Startup Lua can be accessed easily through the UI5 interface: APPS > Develop Apps > Edit Startup Lua.
(OK, not obvious, I wouldn't have put it there myself!)

Just paste the code, press GO and then remember to SAVE.

If you start putting a number of different routines there, and you want to be sure of not corrupting anything existing, then you can put your code into separate files and use require.  My own Startup Lua has but one line: require "akbooerPackage" which simply loads other sub-modules in the manner described here:

http://forum.micasaverde.com/index.php/topic,13296.msg112631.html#msg112631

...does any of this help to answer your question?
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline Piwtorak

  • Hero Member
  • *****
  • Posts: 988
  • Karma: +4/-0
Re: vacation indicator for scenes
« Reply #7 on: May 21, 2013, 04:46:33 pm »
Perfect Akbooer !

I will try follow the steps...

I will let you know.
thanks  for all !
Vera3 (1), Airport Extreme (2), Apple TV (3), Sqblaster (1), GE Switch (3), GE Dimmer (1), Leviton VRCSZ2 (2), GE 45601 (1), Intermatic HA03 (2), GE Zwave Outlet (1), Remote Control Curtain (1) and growing.

Offline Piwtorak

  • Hero Member
  • *****
  • Posts: 988
  • Karma: +4/-0
Re: vacation indicator for scenes
« Reply #8 on: May 21, 2013, 11:47:53 pm »
Akbooer,

your code is perfect. I only changed the ID number and followed your instructions including insert in startup lua.

all works fine and now I have a button in homewave app  to turn my house in vacation mode. my scenes were changed inserting the condition in lua folder.

thanks
Vera3 (1), Airport Extreme (2), Apple TV (3), Sqblaster (1), GE Switch (3), GE Dimmer (1), Leviton VRCSZ2 (2), GE 45601 (1), Intermatic HA03 (2), GE Zwave Outlet (1), Remote Control Curtain (1) and growing.