Author Topic: Setting a scene for away  (Read 14833 times)

Offline tscott

  • Sr. Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
Setting a scene for away
« on: May 09, 2011, 12:28:48 pm »
All - I'm trying to set up a scene to control my Thermostat and Lights when I'm away from the house. And a Home Scene when i'm home. 

From a different thread, i was advised how to program the Thermostat internally and placing it into Engergy Saving Mode.  This works great.  I click the away scene and sets the thermostat to EMS and Home Scene when i want the Thermostat to be in Normal Mode.

I would like to take the scene control one step farther.  I would like multiple lights to turn on and off at preset times to simulate that I'm home.  I have modules in my Entry Way, Study and Bedroom. 

Do i need to create seperate scenes to do this or can I program in the one Away scene? 

Here is what I want;
Away Scene
Thermostat - EMS
Entry Light to turn on at 6pm and turn off at 9pm
Study lamp to turn on at 7pm and turn off at 10pm
Bedrrom lamp to turn on at 9pm and turn off at 11pm.

Thanks in advance for any advise.

Offline anthonyris

  • Full Member
  • ***
  • Posts: 239
  • Karma: +5/-1
Re: Setting a scene for away
« Reply #1 on: May 09, 2011, 10:19:21 pm »
A scene is a way of combining a number of commands, events, timers into one "Action". Being able to define basic scenes with multiple commands is the 1st step to having a powerful home automation setup.

For example, my "House Lockdown" scene:
  • sets all of my lights to off
  • arms my motion sensors (after 5 minute delay)
  • turns off the outlets that control my TV/Stereo/CableBox
  • sets the Thermostat to ESM
  • turns off the outlets that control my TV/Stereo/CableBox
  • shuts off my Ooma Telo (phone)
  • etc. etc.

I also have a Scene named Security Lights that turns on a few different lights X minutes after sunset, and then sets them back to their previous state after Y minutes. Each light has a different length of time it stays on. This Scene runs all by itself (because it's triggered by an Event and/or Timers).

You might want to check the documentation on Scenes. I know the docs aren't great, but they give you a start. Start here:
http://docs2.mios.com/doc.php?language=1&manual=1&platform=0&page=setup_wizard
and
http://docs2.mios.com/doc.php?language=1&manual=1&platform=0&page=scenes_tab
« Last Edit: May 09, 2011, 10:30:12 pm by anthonyris »
Vera3x2, Leviton, GE dimmers, relays and lamp modules, Sonos, Nests...

Offline wscannell

  • Full Member
  • ***
  • Posts: 157
  • Karma: +0/-0
Re: Setting a scene for away
« Reply #2 on: May 09, 2011, 10:40:29 pm »
What you want to do is a bit complicated, but it can be done.  For each separate time that you want an action to be done, you need to have a separate scene.  I would create an on scene for each light and an off scene for each light.  You could have them turn on at a certain time and turn off at some delta time.  However, this is not 100% reliable.  If you lose power to your Vera or it happens to reboot, the things that are delayed will not happen.

Next you need to use a virtual switch to indicate whether you are away or home.  This is simply like a real switch but there is no actual switch attached to what shows in the dashboard.  More about this later.

Now when your scenes are created, they will run every day.  To allow them to run only when away, you turn the away virtual switch on.  Add some luup code to each scene that you want to operate only in away mode:

local away
away = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status",nn)
if(away=="0")then
  return false
end

Where the nn appears above, insert the device ID of the virtual switch.  This can be found on the top of the settings page of the virtual switch.  This code will prevent the scene from doing anything if the virtual switch is in the off position.

For instructions on how to implement a virtual switch see replies 3 and 4 of:

http://forum.micasaverde.com/index.php?topic=6259.0

« Last Edit: May 09, 2011, 10:45:03 pm by wscannell »

Offline anthonyris

  • Full Member
  • ***
  • Posts: 239
  • Karma: +5/-1
Re: Setting a scene for away
« Reply #3 on: May 09, 2011, 10:53:47 pm »
wscannell: Pls don't take this the wrong way, but I don't understand why the recommendation to a clearly-brand-new-Vera-user would start with editing luup code and creating virtual switches. Yes, most of us do that, but then again we're (stupid/crazy/obsessed/relentless?!?) experienced Vera users with scars to prove it.

IMHO, most of what he wants to do can be done via the standard Scenes, Commands, Timers and Events.

Let's guide him, and others, to the 90% solution that doesn't require 3 eyes of newt and a cauldron of boiling batwing!  ;-)

.//A.
Vera3x2, Leviton, GE dimmers, relays and lamp modules, Sonos, Nests...

Offline oTi@

  • Beta Testers
  • Master Member
  • *****
  • Posts: 4041
  • Karma: +32/-6
  • UI what ?!
Re: Setting a scene for away
« Reply #4 on: May 09, 2011, 11:05:28 pm »
For instructions on how to implement a virtual switch see replies 3 and 4 of:
http://forum.micasaverde.com/index.php?topic=6259.0
@tscott,

Should you be interested in noodling with virtual switches, see reply 5 for the latest implementation that should work out of the box.
Dezwaved at the moment...

Offline tscott

  • Sr. Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
Re: Setting a scene for away
« Reply #5 on: May 10, 2011, 10:50:17 am »
All thanks for the help.  I think i understand.  I have used the d_ and I_ statedevice.xlm files ans created the virtual switch.  I have created a scene with a timer to turn on a light.  I'm a bit lost now on how to link the together.  I'm not a programmer by any means, but can navigate through it with a little direction.

I will continue to figure this out.  I appreciate all the help so far.  The forum is full of great information; just finding what information can help is a bit difficult.

Offline JOD

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1973
  • Karma: +4/-0
Re: Setting a scene for away
« Reply #6 on: May 10, 2011, 03:33:51 pm »
Quote
I'm a bit lost now on how to link the together.

When you've created the scenes you want to run when you are "away" you need an indicator that shows when you are away. Thats where the virtual / state device comes into play.

We will assume when the state device is "On" you are home and when it's 'Off" you are away. Only when the State device is off is when your away scenes will run.

Drop the code that @wscannell posted above into the Luup area of each "Away" scene and change the "nn" to that of the state devices device number:
Code: [Select]
away = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status",nn)
if(away=="0")then
  return false
end

Click save on the Luup tab and then save on the dashboard.

Check the scenes. Turn the virtual device "Off" (you are away) and click run scene. The scene should run.
Turn the virtual device "On" (you are home) click run scene. The scene should not run.

Hope that helps.

*Edit. As oTi@ points out below, this scenario is the reverse of what was called for and is my "Home" setup not "Away"  Please adjust your scene setup accordinly.


JOD.
« Last Edit: May 10, 2011, 11:22:42 pm by JOD »
I'm sorry, my responses are limited. You must ask the right questions.

Offline JimMac

  • Sr. Member
  • ****
  • Posts: 307
  • Karma: +2/-1
Re: Setting a scene for away
« Reply #7 on: May 10, 2011, 03:59:30 pm »
You'll find more info and examples of virtual devices and some usage examples here:
http://forum.micasaverde.com/index.php?topic=2826.0

Offline tscott

  • Sr. Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
Re: Setting a scene for away
« Reply #8 on: May 10, 2011, 05:07:46 pm »
Quick Questions:

In the Lump Code, Does 1 = on and 0 = off?

Is there a way to change "on" to read Away and "off" to read Home on the virtual buttons?

 

Offline oTi@

  • Beta Testers
  • Master Member
  • *****
  • Posts: 4041
  • Karma: +32/-6
  • UI what ?!
Re: Setting a scene for away
« Reply #9 on: May 10, 2011, 05:44:24 pm »
In the Lump Code, Does 1 = on and 0 = off?
Yes.

Quote
Is there a way to change "on" to read Away and "off" to read Home on the virtual buttons?
No, not currently, I believe. (@JOD was looking into it.)

I guess @JOD's example may do the opposite of what was promised. It returns false when the state device has status 0, meaning the scene is aborted (i.e. the commands not executed) when the state device is off.

Of course it all depends on what you want, and what you want Home / Away to be.

Do check out @JimMac's stuff too, as suggested; lots of info there.
« Last Edit: May 10, 2011, 05:54:44 pm by oTi@ »
Dezwaved at the moment...

Offline JOD

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1973
  • Karma: +4/-0
Re: Setting a scene for away
« Reply #10 on: May 10, 2011, 06:49:24 pm »
I guess @JOD's example may do the opposite of what was promised.
Hey hey hey, I made no promises!! Actually I made assumptions.
But thats a typical scenario, you get a piece of code and you work with it and make adjustments. OR, as oTi@ points out you make the poster eat crow.  :P
Ok, so if it's inverted as to how you want the Virtual Device to display (the light is on but no one is home) then you could install the inverted D_ file which should give you the opposite effect.

*Edit. As oTi@ points out above, this scenario is the reverse of what was called for and is my "Home" setup not "Away"  Please adjust your scene setup accordingly.
OR you can change the code from (away=="0") to (away~="0")

JOD.

« Last Edit: May 18, 2011, 10:32:53 pm by JOD »
I'm sorry, my responses are limited. You must ask the right questions.

Offline tscott

  • Sr. Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
Re: Setting a scene for away
« Reply #11 on: May 10, 2011, 09:50:12 pm »
Got it - The Virtual Switch Works Perfectly.  The Lights are turning on / off with the timers based on the on / off on the switch.

Now my last question.  I have two scene for the my Thermostat.  One sets to EMS and the other sets to Normal.  Can I link the Virtual Switch to those scenes?  Is it possible to run the scene based on the input from the virtual switch?

Thanks

Offline oTi@

  • Beta Testers
  • Master Member
  • *****
  • Posts: 4041
  • Karma: +32/-6
  • UI what ?!
Re: Setting a scene for away
« Reply #12 on: May 10, 2011, 09:56:23 pm »
In the thermostat scenes, use an event based on whether the virtual switch is switched on or off.
Dezwaved at the moment...

Offline tscott

  • Sr. Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
Re: Setting a scene for away
« Reply #13 on: May 11, 2011, 07:38:58 pm »
I'mnot  having success to get the scene to run when I change the Virtual Switch on/off. 

Is there anything i need to program to force the scene to run?

Offline JOD

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1973
  • Karma: +4/-0
Re: Setting a scene for away
« Reply #14 on: May 11, 2011, 08:09:56 pm »
Is the scene functional without code?
Did you add the code to the Luup tab?
Does the code have the State Device device number?

JOD.

I'm sorry, my responses are limited. You must ask the right questions.