luup.is_night stopped working ? - RESOLVED

Hi

I’m sure this was working before, now it appears not to be working.

if (luup.is_night()) then lul_args["SceneNum"]="31" luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","RunScene",lul_args,0) end

Does that code look correct ? When I run a scene, if it is night I want that scene to run a second scene.

Its night time now, I ran my “Welcome Home” scene which bypasses a door sensor and it should have also run another scene called “Downstairs Lights On” (Scene#31). But the “Downstairs Lights On” scene is now not running when I run the “Welcome Home” scene even though it is currently night.

Many Thanks

I just found the test luup code feature under Develop apps, I get code failed.

Here is a thread with a similar problem. I just tried changing the timezone from London to another city and then back again but its still not working. :-[ Just sent a message to support hopefully they can fix it. Strange problem this and a little worrying if it does it again? My VeraLite has been pretty rock solid so far but things like this makes me worry about if stuff is going to run when it should.

So you’re saying it runs without checking to see if it’s night?

lul_args["SceneNum"]="31"
luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","RunScene",lul_args,0)

No it doesn’t run at all now, the second scene that is, specified by the scene number in the Luup code.

Have a peek at @aa6vh’s code, and/or try the following:

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

And (assuming the code you showed is all you have for that scene), put a [font=courier]return true[/font] at the end.

[quote=“oTi@, post:6, topic:172981”] luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","RunScene",{SceneNum="31"},0)

And (assuming the code you showed is all you have for that scene), put a [font=courier]return true[/font] at the end.[/quote]

Many thanks for your help!

I just tried the new code with luup.is_night. I ran the “Welcome Home” scene and the “Downstairs Lights On” scene (AKA Scene #31) did not run. However that is correct as its still day time at the moment.

I then as a test removed the luup.is_night part just to see if that luup code you gave me does indeed run the scene #31. Now when I run the Welcome “Home” scene the “Downstairs Lights On” scene #31 is also run, which says the new code to run the scene is working

I will add back in the luup.is_night part and test again later when it gets dark.

So the current code is now:

if (luup.is_night()) then luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","RunScene",{SceneNum="31"},0) end

I can also confirm that @aabvh’s code works

lul_args = {} lul_args["SceneNum"]="31" luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","RunScene",lul_args,0)

Looking at my code I posted at the start of this thread it looks like I had this part missing “lul_args = {}” which might have been the problem!

So I will also try this code tonight as well:

if (luup.is_night()) then lul_args = {} lul_args["SceneNum"]="31" luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","RunScene",lul_args,0) end

Is this the correct place to add return true ?

if (luup.is_night()) then return true lul_args = {} lul_args["SceneNum"]="31" luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","RunScene",lul_args,0) end

No, add it as the last line before the end statement.

  • Garrett

[quote=“garrettwp, post:10, topic:172981”]No, add it as the last line before the end statement.

  • Garrett[/quote]

Garrett thanks!

I changed the code to this now, will test when its dark hopefully it will work now.

if (luup.is_night()) then lul_args = {} lul_args["SceneNum"]="31" luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","RunScene",lul_args,0) return true end

Exactly! (If you run your original code, you can take a look at the logs and see if any errors show up. It was pointing at this stuff, and not the [font=courier]luup.is_night()[/font] part of it.)

I’d put the [font=courier]return true[/font] as the very last line, so you know for sure that the (non-Luup) commands in your Welcome Home scene are run (i.e. the sensor is put in bypass etc.).

Exactly! (If you run your original code, you can take a look at the logs and see if any errors show up. It was pointing at this stuff, and not the [font=courier]luup.is_night()[/font] part of it.)

I’d put the [font=courier]return true[/font] as the very last line, so you know for sure that the (non-Luup) commands in your Welcome Home scene are run (i.e. the sensor is put in bypass etc.).[/quote]

OK thanks I will put it on the last line then as you suggest!

It seems to be working Ok! :slight_smile:

Its dark here now, I just ran the Welcome Home Scene, this by-passes that door contact sensor and now because it is dark the Luup code is also running the scene to turn on the down stairs lights!

Thank you very much for your help.

Think I just fixed my Virtual Switch problem as well so doing well today.