UI5 luup.is_night doesn't work ???

First to get some things clear. Im using UI5 for 3 days now and my scenes with the luup.is_night arent working anymore. My location and timezone are set to my current. Im using the is_night in a if statement and it just doesn’t work anymore ???

In the code screen i show 2 actions i tried to test. First the command with out the if statement so that the second command is execute no matter what the result is. The second part of code after the ##### line is with the if statement. After the code i also copied the results of the log and you can see that nothing is executed with the if statement.
I dont think im doing something wrong as the lua was working before in UI4

luup.is_night()
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "70"}, 4)

results:
08	06/17/10 21:16:01.973	JobHandler_LuaUPnP::HandleActionRequest argument Code=luup.is_night()
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "70"}, 4) <0x5015>
08	06/17/10 21:16:02.012	JobHandler_LuaUPnP::HandleActionRequest device: 4 service: urn:upnp-org:serviceId:Dimming1 action: SetLoadLevelTarget <0x5015>
08	06/17/10 21:16:02.012	JobHandler_LuaUPnP::HandleActionRequest argument newLoadlevelTarget=70 <0x5015>
06	06/17/10 21:16:02.013	Device_Variable::m_szValue_set device: 4 service: urn:upnp-org:serviceId:Dimming1 variable: LoadLevelTarget was: 50 now: 70 #hooks: 0 upnp: 0 v:0x8

###########

if luup.is_night() then
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "65"}, 4)

end

results:
08	06/17/10 21:17:38.564	JobHandler_LuaUPnP::HandleActionRequest device: 0 service: urn:micasaverde-com:serviceId:HomeAutomationGateway1 action: RunLua <0x5015>
08	06/17/10 21:17:38.565	JobHandler_LuaUPnP::HandleActionRequest argument Code=if luup.is_night() then
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "65"}, 4)

end <0x5015>
02	06/17/10 21:17:46.016	ZW_Send_Data node 9 USING ROUTE 255.44.49.51 <0xc04>
04	06/17/10 21:17:46.194	 <0x803>

I have Vera Lite with UI5 and this code is working fine for me:

if (luup.is_night()) then
return true
else
return false
end

Im using a Vera 2 and i did notice that the vera background (of the webinterface) didn’t show a night picture which it did with UI4. However i dont know if it does show a night picture ?

I believe that ‘feature’ has disappeared from UI5 indeed.

that 'feature' has disappeared from UI5
It's a shame, we put so much effort into trying to obtain those features. I'm not sure why they removed it. It was a nice indicator of Sunset and when return luup.is_night() was in effect, which BTW works for me in UI5.

JOD.

[quote=“JOD, post:5, topic:170413”]

that ‘feature’ has disappeared from UI5
It’s a shame, we put so much effort into trying to obtain those features. I’m not sure why they removed it.
It was a nice indicator of Sunset and when return luup.is_night() was in effect, which BTW works for me in UI5.[/quote]
Yeah, I liked it too. I suppose we could put it on our wishbug list (i.e. Vera UI too bright at night :slight_smile: ).

([tt]luup.is_night()[/tt] appears to work for me as well.)

I cant get it why its working with everyone and not by me. Just to be sure I also did a full power-down of my Vera. (normally it runs on a backupped powersupply)

[code]if (luup.is_night()) then
luup.call_action(“urn:upnp-org:serviceId:Dimming1”,“SetLoadLevelTarget”, {newTargetValue = “100”}, 11)
luup.call_action(“urn:upnp-org:serviceId:Dimming1”, “SetLoadLevelTarget”, {newLoadlevelTarget = “75”}, 4)

end
[/code]
I triple checked the code but i just dont see why i wouldn’t work ??? (code does work without the if statement )

It appears you have an extra “)”

(luup.is_night())
vs
(luup.is_night()

JOD.

Can you paste the following in [tt]Apps[/tt] > [tt]Develop Apps[/tt] > [tt]Test Luup code (Lua)[/tt] and hit the [tt]Go[/tt] button:

if (luup.is_night()) then
  return true
else
  return false
end

And then replace it with the following and hit [tt]Go[/tt]again:

if (luup.is_night()) then
  return false
else
  return true
end

And report which test produced Message sent successful., and which produced Code failed.?

Tested it twice, once when it was getting dark and once when it was really dark
But both times i did get the same result.

if (luup.is_night()) then return true else return false end
Code failed

if (luup.is_night()) then return false else return true end

Message sent successful.

Then only thing which is coming to mind is that maybe at a complete different moment of the day that the code is_night give a true result.

@The-Source
You should submit a trouble ticket and let me know the ticket number. This is a very strange error.

Not sure how the function works, but presumably it relies on Vera knowing your location so it can work out sunset/sunrise. Maybe a silly question, but have you entered your location?

[quote=“mcvflorin, post:11, topic:170413”]@The-Source
You should submit a trouble ticket and let me know the ticket number. This is a very strange error.[/quote]
I just created a ticket #92940.
And i enable tech support access

@racarter
In my first post i mentioned the part of location and time zone :wink:

Yep - shoulda noticed that! :-[

Strange that it seems to work for some (including me) but not for others. Weird.

I tested the is_night function, day and night, and it seems to work well for me using VeraLite.

Well i did some test at 10AM and 2PM but it still fails with the luup code:

if (luup.is_night()) then return true else return false end

So it isn’t using some other timezone…

@The-Source
At 10 AM and 2 PM it’s day, so it’s normal that code will fail.

I logged in on your Vera and it seems that the function is working OK. However, a Luup restart is required after the timezone is changed, even if the time is updated.

50      02/13/12 11:22:27.887   luup_log:0: It is day. <0x4c14>
50      02/13/12 2:23:02.612    luup_log:0: It is day. <0x4c14>
.
. Luup restart.
.
50      02/13/12 2:23:46.523    luup_log:0: It is night. <0x4c14>
50      02/13/12 2:23:57.664    luup_log:0: It is night. <0x4c14>
50      02/13/12 11:24:32.215   luup_log:0: It is night. <0x4c14>
50      02/13/12 11:24:36.861   luup_log:0: It is night. <0x4c14>
50      02/13/12 11:24:48.817   luup_log:0: It is night. <0x4c14>
50      02/13/12 11:24:58.178   luup_log:0: It is night. <0x4c14>
.
. Luup restart.
.
50      02/13/12 11:25:53.949   luup_log:0: It is day. <0x4c14>

Well its working now, strange thing that a full power cycle didn’t fix it ??? Maybe a ntp update combined with NO luup engine restart was the bugging thing :wink:

Well, it is strange but I am seeing the same problem. When I try to just test the code below I receive a “Code Failed” message

if (luup.is_night()) then
return true
else
return false
end

So I broke it down even further and just tried testing “return false” and still get the “Code Failed”. If I change ti to “return true” then I get “message sent successful”.

I might be wrong in how to restart Lua… is it just the reload button on top?

@Ned
Those messages are normal. When you return false in Test Luup code it means that the code failed, even if it’s correct.