We have moved at community.getvera.com

Author Topic: The "Lived-in" look; lighting timer randomness available?  (Read 21008 times)

Offline CMRancho

  • Hero Member
  • *****
  • Posts: 1008
  • Karma: +1/-0
Re: The "Lived-in" look; lighting timer randomness available?
« Reply #15 on: April 01, 2011, 11:06:26 am »
Having lights go on and off randomly is not necessary. It's only the lights going on and off that makes any difference. Just create a few scenes that turn various lights on or off at different times. The fact that it's the same every night won't make any difference.

If you think bad guys have the patience to watch your house night after night to detect patterns in the cycles, you're giving them way to much credit.
Vera123beta; Schlage, Kwikset, TZEMT400; Linksys cams, Smarteye cams, HSM100; Aeon, Everspring, Cooper, Leviton, Intermatic, FortrezZ, Global Caché, USB-UIRT, Somfy, etc.

Offline MNB

  • Hero Member
  • *****
  • Posts: 689
  • Karma: +4/-9
Re: The "Lived-in" look; lighting timer randomness available?
« Reply #16 on: April 01, 2011, 12:01:06 pm »
I agree @Ap15e considering that most of us have a combination of lights turning On/Off on via various schedules and the random manual On/Off lights it would be nice to capture a weekday vs weekend scenario and then add a random +/-25 mins to each if possible.

I see from earlier thread post that @Guessed was going down the path with his initial code but did not finish, is there someway to combine @Ap15e recording methodology and @guess code to make a prototype "Lived-In" scene? It seem strange that for a "Home automation" solution that to date we don't have a plug-in for this. Mike
Edge-1.7.2607, VRI06-1LX Dimr (6), VS05-1LX Sw (4), GE ZW3002 Dimr (1), HA01C Outlet (12), HA02C Sw (6), HA04C Sw (4), GE Sw (2), HA05 Sw (3), MiniMote Contr (5), HSM200/100 Sensor (2), ZW100A Sensor (8), Nest thermostat (1) & Protect Fire/CO (6) Kwikset Locks (3), F18918W (1) & IP3M-9 (6) Cam's

Offline glaso

  • Jr. Member
  • **
  • Posts: 59
  • Karma: +0/-0
Re: The "Lived-in" look; lighting timer randomness available?
« Reply #17 on: April 01, 2011, 02:02:50 pm »
I Agree with Michael. The random feature is in almost every Home Automation solution out there. I also agree that this could be accomplished using scenes and other features already in Vera.
But, wouldn't be nicer and easier to have a function specifically designed for that. The more simple the better. I imagine a plugin in which you assign which lights will be part of the scene, max/min time for each and maybe max/min number of lights that could be on at a time.
Then you could use normal scenes to activate / deactivate the function.

Offline Les F

  • Hero Member
  • *****
  • Posts: 567
  • Karma: +7/-0
Re: The "Lived-in" look; lighting timer randomness available?
« Reply #18 on: April 01, 2011, 02:10:17 pm »


I have been using things like "off at sunset +6 hours" etc... its not random
but at least the off time is a slowly moving target...

Google+ http://bit.ly/2MAVlkR / Instagram: http://bit.ly/2lIcsFT / Pinterest http://bit.ly/2KCSYRm (Yes, Pinterest is for guys too! take a look)

Offline JimMac

  • Sr. Member
  • ****
  • Posts: 309
  • Karma: +2/-1
Re: The "Lived-in" look; lighting timer randomness available?
« Reply #19 on: April 01, 2011, 02:59:40 pm »
I find the "lived in look" is a required scenario for my house, rental and garage.  Standard timers that turn lots of light on at one time just don't cut it for me so I have been using Luup code to create the custom environment I need.  I have ground floor lights randomly go on just after sunset and randomly go off at different times. Later on at night the bedroom and bathroom lights take their turn, randomly on/off.

  The code I use has three settings; random turn on time, minimum on time and random off time.  A scene is created but it only has Luup code, it does not necessarily need to turn anything on or off in the GUI.  My scenes usually starts with a timer, as an example one of my bedrooms is set to activate the scene @ 9:50pm.  Sunset in this case does not work as you will need to constantly adjust the time as the seasons change.   In the code sample below I have added a few extra settings to make life easier, first I have a logical switch representing if I'm home or not.  This switch changes states when I enter a door code (welcome Home) or press the exit button, On=home, off=away.  If I'm home I don't want the lights doing their thing plus I also check to make sure its dark out.

Here is the Luup code with comments added.


-- Description: Light on within 20min of scene activation, stay on for 13m then off withing 10min

-- Find the status of the logical "House occupied" switch
local house_occupied=luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status",49)

-- Exit if the house is occupied or it's not night time
if (house_occupied == "1") or not ( luup.is_night() ) then
 return false
end

-- Setup local variables for random time on & off  (in seconds) plus the device to control
local Device1 = 15
local RandOnTime1 = 1200
local On1 = 800
local RandOffTime1 = 600

local RanNumbOn1 = (math.random() * RandOnTime1 )
local RanNumbOff1 = (math.random() * RandOffTime1 )

function DelayOn1()
luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ newLoadlevelTarget="70" },Device1)
-- Keep light on for preset time
luup.call_timer("StayOn1", 1, On1 , "", "")
end

function StayOn1()
-- Start the random off timer for light 1
luup.call_timer("DelayOff1", 1, RanNumbOff1, "", "")
end

function DelayOff1()
-- Turn light off
luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ newLoadlevelTarget="0" },Device1)
end

-- It all starts here - Start the random timing for light 1
luup.call_timer("DelayOn1", 1 , RanNumbOn1,"","")


The Device1 number is the device number of the light you want to control.  I have many variations of this code for example:
  A scene is activated that turns on three lights, make each light turn on randomly then use the off from the scene settings - this avoids the all on at once scenario.
 I can call another scene at the end of any of the three timers.  Great for randomly controlling a second set of lights.

A simple cut/past and minor edit should work if you want to use this code.  


Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: The "Lived-in" look; lighting timer randomness available?
« Reply #20 on: April 01, 2011, 03:46:09 pm »
Quote
If you think bad guys have the patience to watch your house night after night to detect patterns in the cycles, you're giving them way to much credit.

Well, it's a tradeoff between effort and expected revenue ...  :)

Offline MNB

  • Hero Member
  • *****
  • Posts: 689
  • Karma: +4/-9
Re: The "Lived-in" look; lighting timer randomness available?
« Reply #21 on: April 02, 2011, 02:58:49 pm »
@JimMac, thanks for code, question  is the house occupied device 49 aka your house lock? also how does the logical  switch work; if I use the exit button on my lock what differation from a normal lock vs vacation lock? I'm assuming that the welcome home is a unique key that turns off the thsi Luup code? Mike
Edge-1.7.2607, VRI06-1LX Dimr (6), VS05-1LX Sw (4), GE ZW3002 Dimr (1), HA01C Outlet (12), HA02C Sw (6), HA04C Sw (4), GE Sw (2), HA05 Sw (3), MiniMote Contr (5), HSM200/100 Sensor (2), ZW100A Sensor (8), Nest thermostat (1) & Protect Fire/CO (6) Kwikset Locks (3), F18918W (1) & IP3M-9 (6) Cam's

Offline JimMac

  • Sr. Member
  • ****
  • Posts: 309
  • Karma: +2/-1
Re: The "Lived-in" look; lighting timer randomness available?
« Reply #22 on: April 02, 2011, 06:16:01 pm »
Device 49 is my virtual device switch (see this forum on how to create a virtual device switch)  It looks like a switch but it is only virtual no real switch exists.  Just think of it as a flag.  My Welcome home scene turns it on and my exit scene turns it off.  All my Luup code in my lighting scenes check the state of this switch and either executes the away lighting or skips it if we're home (same for my alarm scenes).  I find that toggling a virtual switch is best done with Luup coding not through the scene devices. The day I found out how to do this my system became much easier to live with.



« Last Edit: April 02, 2011, 09:05:05 pm by JimMac »

Offline MNB

  • Hero Member
  • *****
  • Posts: 689
  • Karma: +4/-9
Re: The "Lived-in" look; lighting timer randomness available?
« Reply #23 on: April 06, 2011, 08:36:48 pm »
JimMac, re-reading you virtual switch you indicate that your welcome home scene turns it on and my exit scene turns it off.. The logic seems reverse I would have thought that the welcome home would turn your random code off and Off would indicate that your not home. With help of Ap15e, I was able to create a SD and created a test scene to turn on a specific light when the SD was switched "On", I then created another test scene to turn off the specific light again triggered by the SD state when switched to "Off". I can see the advantage but am trying to get my head around how to best use it. Also I'm assuming that previous random code goes into a scene that drives a single light if I want it to turn on other scene how is this possible? thanxs Mike
Edge-1.7.2607, VRI06-1LX Dimr (6), VS05-1LX Sw (4), GE ZW3002 Dimr (1), HA01C Outlet (12), HA02C Sw (6), HA04C Sw (4), GE Sw (2), HA05 Sw (3), MiniMote Contr (5), HSM200/100 Sensor (2), ZW100A Sensor (8), Nest thermostat (1) & Protect Fire/CO (6) Kwikset Locks (3), F18918W (1) & IP3M-9 (6) Cam's

Offline JimMac

  • Sr. Member
  • ****
  • Posts: 309
  • Karma: +2/-1
Re: The "Lived-in" look; lighting timer randomness available?
« Reply #24 on: April 08, 2011, 09:14:27 am »
My welcome home turns it on, exit off, I like to think that someone is home when the lights are on.  The state of the switch does not matter as long as you test for the correct condition.
If you create lots of away lighting scenes you only want these lights doing their thing when your away so have Lup code in each scene that test if your home, if you are home don't run the scene otherwise run them.  Another example is I have multiple scenes that detect motion at night and turn on various lights at 10% so you can see your way. These scenes activate lights when we're home BUT if we are not then instead of turning on lights it activates my alarm siren and strobe lights.  This is all done using the same scene.  One more example, I have a rental cabin, if it is occupied the water heater is turned on otherwise it is kept off all by using a logical switch as a test flag.

Offline JimMac

  • Sr. Member
  • ****
  • Posts: 309
  • Karma: +2/-1
Re: The "Lived-in" look; lighting timer randomness available?
« Reply #25 on: April 08, 2011, 10:50:43 am »
Michael_N_Blackwell
I forgot to tell you how to activate another scene from within an existing scene using Lup codding.  Here is an example of calling another scene using Luup code from within a scene.

-- This code turns on the "house is occupied" logical switch and if it is dark out call scene 9.

-- Turn on logical switch device 49 - Are we home = yes
luup.variable_set("urn:upnp-org:serviceId:SwitchPower1","Status",1,49)

-- If it is dark out call scene 9
if ( luup.is_night() ) then
luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","RunScene",{ SceneNum="9" }, 0)  
return False
end

I exit the first scene once I call the second scene (#9) without executing any commands in the original scene but I don't have to do this.  I can exit "true" or remove the "return false" if I want to proceed with all the commands in scene 1 as well.  I use this technique often since it can reduce the number of independent scenes and simplifies the order and way of executing them with advance boollean logic.

Hope this helps... ( This is part of my Welcome home scene @ night)

« Last Edit: April 08, 2011, 11:03:48 am by JimMac »

Offline MNB

  • Hero Member
  • *****
  • Posts: 689
  • Karma: +4/-9
Re: The "Lived-in" look; lighting timer randomness available?
« Reply #26 on: April 08, 2011, 12:22:09 pm »
JimMac,

Many thanks, I will have to read this a few times to get my head around the concept (a little slow ;D). I can see the advantage, just needed a few pointers (which you provided) to proceed. I would have thought there would have been a "How to for dummies" somewhere e.g wiki. It seems that some of us Lua challenged folks are trying to piece meal via the many related thread with limited success (Ok I'll stop my whinning) again thanks for the comeback.
Edge-1.7.2607, VRI06-1LX Dimr (6), VS05-1LX Sw (4), GE ZW3002 Dimr (1), HA01C Outlet (12), HA02C Sw (6), HA04C Sw (4), GE Sw (2), HA05 Sw (3), MiniMote Contr (5), HSM200/100 Sensor (2), ZW100A Sensor (8), Nest thermostat (1) & Protect Fire/CO (6) Kwikset Locks (3), F18918W (1) & IP3M-9 (6) Cam's

Offline JimMac

  • Sr. Member
  • ****
  • Posts: 309
  • Karma: +2/-1
Re: The "Lived-in" look; lighting timer randomness available?
« Reply #27 on: April 08, 2011, 12:46:04 pm »
I realize that many people are not programmers that is why I have added many comments in my codding to help you break down what each section or line of code does.  There are so many different things you can do with Lua coding and I try to make it as simple as cut/paste + minor edit for everyone.  I have been on this forum for many years and have found that not too many people are willing to share codding with others.  Maybe it causes too many questions, I'm not sure.  There are the exceptions and thanks to those people who do post as they have helped me and others in learning the language.  You can find those people in the Luup and Development section.

The code for programming is available, the only thing that is not supplied is imagination and the need.
« Last Edit: April 08, 2011, 01:14:27 pm by JimMac »

Offline MNB

  • Hero Member
  • *****
  • Posts: 689
  • Karma: +4/-9
Re: The "Lived-in" look; lighting timer randomness available?
« Reply #28 on: April 09, 2011, 12:02:27 pm »
JimMac, additional questions;

1) I'm assuming if I want more than one device to turn on that I would simply add additional command statements with each device Id identified e.g Just Confirmed that I can
luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ newLoadlevelTarget="70" },Device1)
luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ newLoadlevelTarget="70" },Device2)
luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ newLoadlevelTarget="70" },Device3)


2) Also on my logical switch (device 49) do I have to have any scene(s) associated with the switch, I would have thought that simply turning it On for Home and Off for Away would be the simple flag or no flag situation that each device would react as Home vs Away? with the;

local house_occupied=luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status",49)

3) In your recent post you have code that turns on the logical switch (device 49)

luup.variable_set("urn:upnp-org:serviceId:SwitchPower1","Status",1,49)

Out of curiousty how are you using this, I know the previously I interact with the device 49 thru the GUI, while this statement is a scene to turn device On? thanxs for the insight. Mike
« Last Edit: April 09, 2011, 01:14:17 pm by Michael_N_Blackwell »
Edge-1.7.2607, VRI06-1LX Dimr (6), VS05-1LX Sw (4), GE ZW3002 Dimr (1), HA01C Outlet (12), HA02C Sw (6), HA04C Sw (4), GE Sw (2), HA05 Sw (3), MiniMote Contr (5), HSM200/100 Sensor (2), ZW100A Sensor (8), Nest thermostat (1) & Protect Fire/CO (6) Kwikset Locks (3), F18918W (1) & IP3M-9 (6) Cam's

Offline JOD

  • Hero Member
  • *****
  • Posts: 1973
  • Karma: +4/-0
Re: The "Lived-in" look; lighting timer randomness available?
« Reply #29 on: April 09, 2011, 12:23:05 pm »


I realize that many people are not programmers that is why I have added many comments in my codding to help you break down what each section or line of code does.

The coding goes along way to adding those finishing touches to an installation. I wish there were more examples in the scripting wiki..
http://wiki.micasaverde.com/index.php/Scripts_for_scenes
Personally I've only just learned "return luup.is_night()" and that there is no "return luup.is_day()" so, thank you for contributing.

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