The Vera Community forums have moved!

Advanced => Programming => Scene Scripting => Topic started by: Intrepid on April 26, 2011, 09:37:09 pm

Title: 45604 outdoor module...go back to previous setting?
Post by: Intrepid on April 26, 2011, 09:37:09 pm
I've got my cool homeseer event working perfectly in vera.  Well, almost perfectly.

I have 4 outside doors with hrds1 sensors and a virtual 'any/all door' device.  If it is night, and any door is opened, the flood lights, front porch light, deck lights (on 45604 outdoor module), side light, and back porch light all turn on.  When ALL doors are closed (via virtual any/all device), the floods and front porch lights turn off after a minute.  I want the 45604 deck lights to also turn off after a minute, but this command option does not seem to work on this module.  It stays on.  My back and side lights are on dusk to dawn, so they receive no command.

In the off scene (triggered by 'any door open' turning off), I'm using the 'turn xxx on, then after one minute go back to previous setting' option for the floods, front, and deck lights.  Floods and front are GE dimmers, the deck is the 45601 outdoor and it does not respond to this 'go back' command.

Should this work, or does 'go back' only work for light/dimmer modules?

Title: Re: 45604 outdoor module...go back to previous setting?
Post by: oTi@ on April 26, 2011, 09:57:34 pm
Should this work, or does 'go back' only work for light/dimmer modules?
I just tried the basic case of a scene with a single outdoor module in it:
- Module is off -> run scene -> module comes on, off after 1 minute.
- Module is on -> run scene -> module comes on, stays on.
So it appears to work.
Title: Re: 45604 outdoor module...go back to previous setting?
Post by: Intrepid on April 27, 2011, 06:30:36 am
Thanks for testing, this is not working for me.  I'll try a different module and see if it's just the one that's not behaving.

.

Title: Re: 45604 outdoor module...go back to previous setting?
Post by: oTi@ on April 27, 2011, 11:26:05 am
Thanks for testing, this is not working for me.
The basic test I did is not working for you, or you're just reiterating that your scene does not work?

At any rate, what happens if you modify the off scene to 'unchanged' and then 'after 1 min go to previous'?

Title: Re: 45604 outdoor module...go back to previous setting?
Post by: Intrepid on April 27, 2011, 11:35:45 am
My scene (same commands as your test) works for two other lights, but not the outdoor module.  I did not re-create your test scene, but I will when I get time.

Thanks for the help.

Title: Re: 45604 outdoor module...go back to previous setting?
Post by: oTi@ on April 27, 2011, 02:32:12 pm
My scene (same commands as your test) works for two other lights, but not the outdoor module.  I did not re-create your test scene, but I will when I get time.
OK. I think my test had 2 points: 1) 'Go back' does do something with the outdoor module. 2) Entering the scene with the light on, leaves it on. Are you sure the scene has 'go back', not just 'off', for the other 2 lights?
Title: Re: 45604 outdoor module...go back to previous setting?
Post by: Intrepid on April 27, 2011, 09:43:48 pm
I created a new scene, and it works like you suggested.  

module is on
scene to go back to previous setting, it stays on

module is off
scene to go back to previous setting, it goes off

Then I went back to my original scene.  Same basic commands except for the 2 additional lights.  Since it was day when I was testing, I removed the luup...


if not ( luup.is_night() ) then
 return false

end

...and all lights and the outdoor module worked properly.  The module turned back off according to the 'go back to previous' condition.  


But tonight, on the same scene, I added back the 'is night' luup, and the outdoor module will not turn back off even if it is originally off.  The other lights turn back off fine.

I'm stumped.

Anyway, I have a scene to automatically turn off the deck lamps (triggered by an on) back off after 1.5 hours, and that might actually work better.  When we're opening the deck door at night, I don't want the deck lights switching...the 1.5 hour  delayed off is probably best.


Title: Re: 45604 outdoor module...go back to previous setting?
Post by: oTi@ on April 28, 2011, 09:33:18 am
[...]
But tonight, on the same scene, I added back the 'is night' luup, and the outdoor module will not turn back off even if it is originally off.  The other lights turn back off fine.
Have you tried
Code: [Select]
if not ( luup.is_night() ) then
 return false
else
 return true
end
OR just
Code: [Select]
return (luup.is_night())
(Or if there is other code there, make sure you return true at the end.)
Title: Re: 45604 outdoor module...go back to previous setting?
Post by: MNB on April 28, 2011, 01:06:46 pm
I have 4 outside doors with hrds1 sensors and a virtual 'any/all door' device.  If it is night, and any door is opened, the flood lights, front porch light, deck lights (on 45604 outdoor module),
Should this work, or does 'go back' only work for light/dimmer modules?
@Intrepid, can provide insight / Code for your "any/all" virtual device as to how your using this, thanxs in advance. Mike
Title: Re: 45604 outdoor module...go back to previous setting?
Post by: Intrepid on April 29, 2011, 05:24:42 am
Oti, thanks for taking the time to help diagnose/understand this.  I'm up early, still dark, so I tried these.


Have you tried
Code: [Select]
if not ( luup.is_night() ) then
 return false
else
 return true
end

This gives the same result as my original without the 'else return true'.  other lights turn back off, outdoor module does not turn back off.


Quote
OR just
Code: [Select]
return (luup.is_night())
(Or if there is other code there, make sure you return true at the end.)

this does nothing, and none of the lights turn on.  it aborts the scene, i guess?

Title: Re: 45604 outdoor module...go back to previous setting?
Post by: Intrepid on April 29, 2011, 05:44:33 am
I have 4 outside doors with hrds1 sensors and a virtual 'any/all door' device.  If it is night, and any door is opened, the flood lights, front porch light, deck lights (on 45604 outdoor module),
Should this work, or does 'go back' only work for light/dimmer modules?
@Intrepid, can provide insight / Code for your "any/all" virtual device as to how your using this, thanxs in advance. Mike

Sure!  I'm ultra-new and not a programmer, but I did get this one going.  I've had this working in homeseer for 10 years.  HS allows conditionals in GUI events, but this is actually just as easy in Vera.

I have 4 exterior doors with HRDS1 sensors.  If ANY door is opened (tripped), the 'any door' virtual device turns on.  When ALL 4 doors are closed, the vrtual device turns off.  

I mainly use this for night scenes where I want all exterior lighting (mainly floods) to come on when any exterior door is opened and stay on until all exterior doors are closed.

1. Create a virtual device:
http://forum.micasaverde.com/index.php?topic=2138.0 (http://forum.micasaverde.com/index.php?topic=2138.0)

2. Create 4 scenes (one for each door) called 'door 1 open', 'door 2 open', etc.  Each of these are triggered by the event HRDS1 for being tripped, yes.  And the command of turning 'any door virtual' on.  

3. Create 4 more scenes called 'door 1 closed', door 2 closed, etc.  Each triggered by event HRDS1 tripped, no.   And the luaa:

Code: [Select]
-- Find the status of any doors

local  Door1State= luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", 8)
local  Door2State= luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", 27)
local  Door3State= luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", 28)
local  Door4State= luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", 29)


-- Exit the scene if any door is open
if (Door1State == "1") or (Door2State == "1") or (Door3State == "1") or (Door4State == "1") then
 return false
end

8, 27, 28, 29 are the devices for my HRDS1s.

I'm sure there is a more elegant way to handle this without having 8 scenes, but this was my first attempt, and it works.

Besides the lighting scene being discussed in this thread, It's also handy to have one indicator device to see if any door is open on my iphone.

Hope that helps.

Title: Re: 45604 outdoor module...go back to previous setting?
Post by: Ap15e on April 29, 2011, 08:52:19 am
IIUC, you could get along with only two scenes.

Create scene 1 with all events from step 2.
Create scene 2 with all events from step 3.

Multiple events get OR'ed, see http://wiki.micasaverde.com/index.php/Luup_Scenes_Events#Adding_Lua_code_to_scenes_and_events.
Title: Re: 45604 outdoor module...go back to previous setting?
Post by: Intrepid on May 03, 2011, 09:17:44 pm
I think I see what you're getting at, but how do you do an OR on the EVENT that triggers the scene?  The reason I have 4 open scenes (step 2) is that the triggering even is one trigger (each door open) per scene.  Can I use one scene that is triggered if ANY of 4 hrds1s is tripped?  how?

For step 3, it is similar.  The conditional test (all doors closed) is the same in all 4 scenes, but I have 4 scenes because I don't know how to check conditions on the initial trigger (any of 4 hrds1s closed).

I get the conditions on whether or not to continue the scene, but not to start or activate the scene.

Thanks.
Title: Re: 45604 outdoor module...go back to previous setting?
Post by: wscannell on May 03, 2011, 09:47:09 pm
Instead of creating one event per scene, use four events for your scene.  If any one of the four events occur, the scene will run the commands and the Luup code.  If I understand correctly, your Luup and the commands are the same for the four door open scenes, then this will work.  Similarly, the same would work to make just one door closed scene.
Title: Re: 45604 outdoor module...go back to previous setting?
Post by: Intrepid on May 03, 2011, 09:57:31 pm
Wow, now I see it, you can have multiple events for a scene.  A month with the vera and I didn't notice that. 

I assume they are OR events?

Thanks
Title: Re: 45604 outdoor module...go back to previous setting?
Post by: wscannell on May 03, 2011, 10:30:04 pm
Yes, the events are ORed.  Also, you can add multiple timers as well, which are also ORed.  The scene will each time any event occurs or each time any timer fires.
Title: Re: 45604 outdoor module...go back to previous setting?
Post by: Intrepid on May 04, 2011, 07:39:07 am
Thanks for the tips.  I just cut 8 scenes (4 open, 4 closed) down to 2.

The multiple events ORs is so obvious now, but I just never noticed it in the interface.

Title: Re: 45604 outdoor module...go back to previous setting?
Post by: oTi@ on May 04, 2011, 08:17:08 am
I just cut 8 scenes (4 open, 4 closed) down to 2.
Great! (BTW, here's the flowchart (http://wiki.micasaverde.com/images/thumb/8/8a/SceneFlowchart.png/800px-SceneFlowchart.png).)

You still have the different behavior for 'go back to previous setting', right?
Title: Re: 45604 outdoor module...go back to previous setting?
Post by: Intrepid on May 04, 2011, 09:26:53 am
Yes, the outdoor module 'go back' with the isnight check still does not work. 
Title: Re: 45604 outdoor module...go back to previous setting?
Post by: Henk on June 06, 2011, 05:48:45 am
@oTi!

Im going to investigate this thread later on during the day...
On forehand... is it possible in an ON scene to have the " ( luup.is_night() )" variable trigger on an event that is hardcoded for time (On at 0600AM when night) but not the second event that is based on sunset (30min before)
Both events created within in the same scene?
Title: Re: 45604 outdoor module...go back to previous setting?
Post by: JOD on June 06, 2011, 10:13:18 am
In the off scene (triggered by 'any door open' turning off), I'm using the 'turn xxx on, then after one minute go back to previous setting' option for the floods, front, and deck lights.  Floods and front are GE dimmers, the deck is the 45601 outdoor and it does not respond to this 'go back' command.
In response to the OP. The device (45604 outdoor module) is not relevant to the issue, Vera is simply turning it On or Off.
Just an observation to your scene setup. 
Assuming the light was already On when the door was closed, triggering the second part of your scene to turn the light On again, the "after one minute go back to previous setting" request would keep the light On. 
Try this as a test: Open your door (event) the light should turn On. Manually turn that light off. Close the door (event) which should turn that light back On, and then it should turn Off after one minute.

JOD.
Title: Re: 45604 outdoor module...go back to previous setting?
Post by: TimAlls on June 06, 2011, 10:24:43 am
In a previous thread I brought up a bug on the GE dimmers I am using.....they would not return to there previous settings (setup in scene control) and that is with no Code added. The GE product line varies from model to model but they have compatibility issues with Leviton and I think even Vera has a hard time with some of them. I would try using a different brand on your outdoor switch IF this feature is a deal breaker.
Regards
Tim Alls
Title: Re: 45604 outdoor module...go back to previous setting?
Post by: MNB on August 03, 2011, 04:15:19 pm
I have 4 outside doors with hrds1 sensors and a virtual 'any/all door' device.  If it is night, and any door is opened, the flood lights, front porch light, deck lights (on 45604 outdoor module),
Should this work, or does 'go back' only work for light/dimmer modules?
@Intrepid, can provide insight / Code for your "any/all" virtual device as to how your using this, thanxs in advance. Mike

Sure!  I'm ultra-new and not a programmer, but I did get this one going.  I've had this working in homeseer for 10 years.  HS allows conditionals in GUI events, but this is actually just as easy in Vera.

I have 4 exterior doors with HRDS1 sensors.  If ANY door is opened (tripped), the 'any door' virtual device turns on.  When ALL 4 doors are closed, the vrtual device turns off.  

I mainly use this for night scenes where I want all exterior lighting (mainly floods) to come on when any exterior door is opened and stay on until all exterior doors are closed.

1. Create a virtual device:
http://forum.micasaverde.com/index.php?topic=2138.0 (http://forum.micasaverde.com/index.php?topic=2138.0)

2. Create 4 scenes (one for each door) called 'door 1 open', 'door 2 open', etc.  Each of these are triggered by the event HRDS1 for being tripped, yes.  And the command of turning 'any door virtual' on.  

3. Create 4 more scenes called 'door 1 closed', door 2 closed, etc.  Each triggered by event HRDS1 tripped, no.   And the luaa:

Code: [Select]
-- Find the status of any doors

local  Door1State= luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", 8)
local  Door2State= luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", 27)
local  Door3State= luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", 28)
local  Door4State= luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", 29)


-- Exit the scene if any door is open
if (Door1State == "1") or (Door2State == "1") or (Door3State == "1") or (Door4State == "1") then
 return false
end

8, 27, 28, 29 are the devices for my HRDS1s.

I'm sure there is a more elegant way to handle this without having 8 scenes, but this was my first attempt, and it works.

Besides the lighting scene being discussed in this thread, It's also handy to have one indicator device to see if any door is open on my iphone.

Hope that helps.


@interpid, I used your recommendation LUA code and just created a single scene for my locks three locks (can be modified for sensors) and in the scene events tab added a open and closed event for each device and then used the following LUA:

-- Find the status of multiple locks
local Lock1State=luup.variable_get("urn:micasaverde-com:serviceId:DoorLock1","Status",26)
local Lock2State=luup.variable_get("urn:micasaverde-com:serviceId:DoorLock1","Status",27)
local Lock3State=luup.variable_get("urn:micasaverde-com:serviceId:DoorLock1","Status",78)
if (Lock1State == "0") or (Lock2State == "0") or (Lock3State == "0") then luup.call_action("urn:upnp-
-- Set Virtual Switch to "Off" because one switch is not locked and exit the scene
org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="0" },85)
 return false
end

In the command tab, I set the virtual device (85) to "ON", (could have done same using LUA after return false command). Seems to work great thanxs for pointers. Mike