Please help with scene code - Make lights stay off in daytime? RESOLVED

Hi

I have created one new scene for use with a new door contact sensor on my garage door. This sensor will be armed 24/7 unless I bypass it to enter the garage. When the garage door sensor is tripped i.e. the door is opened whilst the sensor is armed, it makes the Z-wave siren in the garage go off, and the Luup code below does the following:

Run scene number 56 - This wakes the Windows 7 HTPC in my bedroom
Run scene number 69 - This turns on certain lights inside and outside the house
The socket connection uses MCE Controller to play an alarm.mp3 track in Media Center and the sound comes through the ceiling speakers in the bedroom to wake me up.
I am emailed a notification that the garage door has been opened.

lul_args = {} lul_args["SceneNum"]="56" luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","RunScene",lul_args,0) luup.sleep(2000) lul_args["SceneNum"]="69" luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","RunScene",lul_args,0) lul_args = {} luup.sleep(12000) local socket = require("socket") host = "192.168.0.5" c = assert(socket.connect(host, 5150)) c:send("Alarm-MP3\r") c:close()

All this seems to work well.

My question is, if the garage door sensor is triggered during the day time the lights in the house will come on. How can I set this up so that the lights in the house only come on if its night time?

Also I’ve just setup SMS Phone notifications in the Vera Account tab. I have tested the SMS and they are coming to my phone.
However it looks like I will now get all notifications coming to my phone as well as email ?
I only really wanted SMS notifications for when this garage door sensor is triggered, but not when my other sensors are triggered possible ??

I’ve jumped to this thread here about the SMS issues.

Thanks

Use the luup.is_night() function.

  • Garrett

Garrett thanks!

Does this look right ?

lul_args = {} lul_args["SceneNum"]="56" luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","RunScene",lul_args,0) luup.sleep(12000) local socket = require("socket") host = "192.168.0.5" c = assert(socket.connect(host, 5150)) c:send("Alarm-MP3\r") c:close() if (luup.is_night()) then lul_args["SceneNum"]="69" luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","RunScene",lul_args,0) lul_args = {}

EDIT: Don’t think it is right, when I use this code is says: ERROR : Error in lua for scenes and events

Every if (...) then needs a matching end to tell Lua where to skip to if the test is false.

You are missing the end at the end of the code fragment.

Thanks I think its working now and only turning the lights on at night time!