Scene with gate, lights sunset and sunrise......complicated :-)

Hello all,

I have started a new project and am quite new to all this Zwave. But it is working and I enjoy it. But what I want now is a bit too complicated for me.

Situation:
*Gate (operated by fibaro relais ("simulated springloaded switch for 0,5 secs) for open and shut).
*Light at the gate (fibaro relais)
*garage door operated also by a fibaro siwtch (also simulated as a spring loaded switch).
*light at the garage (fibaro relais)
*light at my front entrance (fibaro relais)

No problem to individualy operate allof them.

I want to make a scene which operates which operates on diferent times dependend on sunset and rise.

For example. I press the button and the gate, garage door goes open , nothing else happends since it is daylight. Second example; I press the button , the gate and the garage door goes open , but since it is now midnight and dark , also the lights go on for 10 minutes.

If possible I want the lights to go on in the scene when it is sunset +15 minutes and I don’t want the lights to go on when it is sunrise-15 minutes.

Is this possible? the 15 minutes is not a real problem , when this is not possible , but it would be nice to programm the lights in depending of the daylight.

many many thanks,
Cor

Hi, I will assume you are using a Vera product.

Your scene is actually very straight forward and all the programming commands you will need are on the web page that controls your vera.

So I’ll try to explain it as I’m a newbie as well

Get to your main web page for the vera then

Click “Automation”
then
Click “New Scene”
then
In the box called “New Scene” put a name in there EG: GateSunset or something
Then
Click all the devices you want to turn on
then
At the far right Click "“Confirm Changes”
then
Above the Confirm Changes click the Red SAVE and wait for the screen to refresh.
then
You will be back at the Automation page
then
Click the wrench on the new scene you have made
then
At the top of the page click “Schedules”
then
Give the Schedule a name EG: ShedGateSunset
then
In shedules options screen select “Day of the Week Based”
then
Select the days you want the scene to run
then
At the time drop down, select “After Sunset”
then
Click “Done”
then
Click “Confirm Changes” and the red “Save”

You will now be back at the automation page, “Run” your newly created scene, if all went well the scene you just programed should turn on/activate the devices you just told vera to control.

If this works for you then use the same steps to make the sunrise scene.

Good luck!

@ Turbo:

Thanks for the reply, I indeed forgot to mention that I have a vera 3.

I thought it was a bit more complicated with luups and so . But this I can do :slight_smile: The 15 minutes is not possible I see , well … not a big problem.

Next week when I am at home I will try it … and keep you posted.

thanks again ,
Cor

Finally some time to play with this.

I was able to insert the sunset/ sunrise, but i don’t think the vera will do what I want.

What I want, when I activate a scene, a device (switch) much activate under all circumstances!
Depending on the time of day (when it is dark) also lights must go on for 5 minutes.

What I think Vera does now ,it will only activate the switch when it’s dark together with the lights :-s

What I did:
*New scene
*device on
*schedule

  • days of weeks based >> all, “after sunset” : 15 minutes
    *done , saved
    *clicked on wrench and also activated the lights in that scene.

I think the scedule will work for all devices , not for only the lights.
Where should I look to change this,something a scene , and that scene is a trigger for two other scenes, one for the gate to open, and the other one to see if the lights go on according the schedule

Or am I thinking to difficult :slight_smile:

Thanks,
Cor

I think you answered your own Q. One easy solution: Create 2 scenes (one for gate and one for lights if dark). Create a 3rd scene to call the other 2 scenes by using 2 lines of LUUP:

luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "RunScene", {SceneNum = "5"}, 0) luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "RunScene", {SceneNum = "6"}, 0)

(see http://wiki.micasaverde.com/index.php/Luup_Scenes_Events#Run_Scene_.235 )

Alternatively, you can create a single scene, but have some LUUP code there to turn on lights only if it’s past sunset and before sunrise … (http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#function:_is_night)

Many thanks…

I think I really need to go into that luup programming :-s … it looks quite complicated.

Anyway , thanks for helping me out here :slight_smile:

Cor

I’d start off more basic than 3 scenes, I would just use 2 for starters.

SceneA)
Devices: Gate & door
Trigger: Button pressed
LUUP: None

SceneB)
Devices: Lights (on immediately, off some time later or “return to previous state” to keep them on if they were on)
Trigger: Button pressed
LUUP: Enter “return luup.is_night()”

SceneA runs every time the button is pressed.
SceneB runs when the button is pressed, but only at night (sunset to sunrise). You could add more checking such that SceneB only runs if the lights are off to begin with (so if you turned them on manually earlier, they will stay on…then you don’t do the “return to previous” - but if you turn them off after the scene starts, they might come back on!).

Once you have those working, you could make things more complicated (with LUUP) by:

  • Using a countdown timer to handle turning the lights off later
  • Using the combination switch or a virtual switch to manage times before/after sunrise/sunset
    (turn the light on/off via a scheduled scene tied to sunrises/sunset, or with heliotrope plugin. Change the LUUP in SceneB to return true if the light is on).

@ CapjayL thanks as well, I first try to do it with 2 scenes.
@ PurdueGuy:

I like your idea and will try to put that Luup code in tomorrow. I also looked in buying a book for learning Luup code , but i think that might be a bit too difficult to learn for a non-programmer :frowning: hopefully you can help me to complete this Luup code.

What I would like is:
in Scene B: Lights on immediately when it is night +15 minutes and previous state is off.
I want those lights to be on for 10 minutes, there after all off.

The “all lights” off after 10 minutes , I guess I can do that easilly in the scene setup , a delay after 10 minutes and than lights to off.

Thanks a lot I appreciate it ,
Cor

what time is considered for “return luup.is_night()”

when the system considers night ?

thanks!!!

the discussion is good !

[quote=“Cor, post:8, topic:172982”]… is night +15 minutes …[/quote]The “+ 15 minutes” with just LUUP code is harder, but can be done. Extensions were added to get the amount of time to the next sunrise/sunset, but there is more to it.

There are a few ways to do it.
0) Don’t worry about the 15 minutes, and make it easier. ;D ;D

  1. First, if “is_night()” fails, you don’t need to do anything, it’s daytime. If it is night, you would need to figure out when the next sunrise is, and sunset, and do the math to figure out if the current time is in the right window. That’s complicated if you aren’t used to that much programming.

  2. Use a virtual switch that gets turned on/off based on sunset+15 & sunrise-15. Use the following LUUP in SceneB, replacing “DEVICE_ID” with the Device # (NOT the Z-Wave node id!!):

virtualSwitchStatus = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status", DEVICE_ID) if (virtualSwitchStatus == "0") then return false end return true

[quote=“Piwtorak, post:9, topic:172982”]what time is considered for “return luup.is_night()”

when the system considers night ?

thanks!!!

the discussion is good ![/quote]
is_night() returns true between sunset and sunrise, based on your current location.

@Piwtorak,

is_night() returns true between sunset and sunrise, based on your current location.[/quote]
Also, see the wiki, use the search function, etc.

Here I am again;

Today I played a bit with the Vera interface, I was able to do it with the way of capjay. Works briliantly :slight_smile:
What I did was make the 3 scenes and used the given luup code in the 3d scene .For the light scene I inserted a schedule, everyday of the week “after sunset” 15 minutes. This worked for last night. I am just wondering when this scene wil not "switch"on anymore, will it stop AT sunrise?

I also tried the luup code from Purduguy, but I couldn’t get the luup code to work , it gave me an error … I am sure I did something wrong here , it’s is still way to new for me.
I made a screenshot:
[url=http://i305.photobucket.com/albums/nn236/corvl/luup.jpg]http://i305.photobucket.com/albums/nn236/corvl/luup.jpg[/url]
After this I clicked “save lua”, thereafter the Red SAVE button from the vera interface. Thereafter it gave me an error saying something like “error in LUA code”.

I tried this:
Enter “return luup.is_night()”
and this:
“return luup.is_night()”

both gave the same error.

I would like to try this option as well.

thanks,
Cor

Omit the quotes. Start with the r and end with the )

Don’t enter the quotes, just what is between the quotes.

I should have used the ‘code’ tag instead:

return luup.is_night()

Thanks … that works now as well :wink:

A question about this scene setup:

scene 1: gate opens
scene 2: light goes on >> schedule “all day of the week”,“after sunset”, “15minutes”.
scene 3: activate scene 1 & 2 with luup code.

At what stage of the day will the light not go on anymore, I expect this to be at sunrise, is this correct?

Cheers,
Cor

[quote=“Cor, post:15, topic:172982”]Thanks … that works now as well :wink:

A question about this scene setup:

scene 1: gate opens
scene 2: light goes on >> schedule “all day of the week”,“after sunset”, “15minutes”.
scene 3: activate scene 1 & 2 with luup code.

At what stage of the day will the light not go on anymore, I expect this to be at sunrise, is this correct?

Cheers,
Cor[/quote]
Based on what you described & how I interpret them, there are some issues with your scenes:

Does Scene2 turn the lights off after some time? (say 10 minutes?)

With a schedule for scene 2, the light will go on every day at sunset, whether you push the button to activate scene 3 or not. You have no “off” commands.

With scene 3 having the luup.is_night() in there, it will only call scene 2 between sunset and sunrise. That means that the lights will come on when you press the button (to activate scene 3) from sunset until sunrise, even though they may already be on from sunset+15.

Hi Perdueguy

I was indeed not complete in my post.

scene 1: gate opens
scene 2: light goes on >> schedule “all day of the week”,“after sunset”, “15minutes”.
scene 2: light goes off after 5 minutes
scene 3: activate scene 1 & 2 with luup luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "RunScene", {SceneNum = "5"}, 0) luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "RunScene", {SceneNum = "6"}, 0)

You are saying that after every sunset + 15 minutes the lights will go on for 5 minutes. Even when scene 2 is not activated by scene 3?
The “luup.is_night()” code is not used in this test!

Interesting:-)

[quote=“Cor, post:17, topic:172982”]scene 1: gate opens
scene 2: light goes on >> schedule “all day of the week”,“after sunset”, “15minutes”.
scene 2: light goes off after 5 minutes
scene 3: activate scene 1 & 2 with luup luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "RunScene", {SceneNum = "5"}, 0) luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "RunScene", {SceneNum = "6"}, 0)[/quote]

I’m assuming you want the lights go on only if activated by scene 3, in this case, remove the schedule in scene 2 (otherwise it will always trigger at the schedule regardless of scene 3) , keep the rest of the settings in scene 2, just go to LUUP section and add the following line:

return luup.is_night()

(which will make scene 2 run ONLY if it’s night time)
try this, if it works as intended we can move to next step (adding 15 min to sunset)

@ Capjay ,

Ok , understood: I was thinking about the post # 4 or 5 in this thread, but it would still need the return luup.is_night(). That’s working now fine (it was last night… I will have to try it again tonight :slight_smile: ).

The 15 minutes is not a big thing , and I will let that go …not important , and too much work to get it working for those 15 minutes :slight_smile:

thanks for your help,
Cor