We have moved at community.getvera.com

Author Topic: if ( luup.is_night() ) then question  (Read 10540 times)

Offline ballroller

  • Sr. Member
  • ****
  • Posts: 286
  • Karma: +0/-0
if ( luup.is_night() ) then question
« on: June 05, 2011, 11:39:47 pm »
For this Luup statement:

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

What defines "night"?

Offline Henk

  • Hero Member
  • *****
  • Posts: 820
  • Karma: +3/-0
Re: if ( luup.is_night() ) then question
« Reply #1 on: June 06, 2011, 05:51:35 am »
@ballroller

I think "night", "not night" "sunset" and "sunrise"  are set based on your regional timezone setting.
| Vera2 @ UI4 1.1.1350 / 3.20 | Vera Lite @ UI5 | Vera 3 @ UI5 | 2x Merten  504519 | 1x Duewi  064374 | 1x Everspring SM103 doorbell mod |1 Y-cam IP cam | various LUUP plugins |

Offline MCV.Eugen

  • Newbie
  • *
  • Posts: 17
  • Karma: +0/-0
Re: if ( luup.is_night() ) then question
« Reply #2 on: June 06, 2011, 06:08:30 am »
According to the wiki (http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#function:_is_night) it returns true if time is between sunset and sunrise, which depends on where you set your location (http://wiki.micasaverde.com/index.php/Location).

Offline Henk

  • Hero Member
  • *****
  • Posts: 820
  • Karma: +3/-0
Re: if ( luup.is_night() ) then question
« Reply #3 on: June 06, 2011, 06:24:11 am »
According to the wiki (http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#function:_is_night) it returns true if time is between sunset and sunrise, which depends on where you set your location (http://wiki.micasaverde.com/index.php/Location).

If this is so (and i agree it is, referring to my own post just below)
Whats the impact of the issue discussed here:
http://forum.mios.com/index.php?topic=6695.0

Some luup variables (f.i. luup.timezone) derive their value from the user_data.
I filed a bug on this issue:
http://bugs.micasaverde.com/view.php?id=1495
| Vera2 @ UI4 1.1.1350 / 3.20 | Vera Lite @ UI5 | Vera 3 @ UI5 | 2x Merten  504519 | 1x Duewi  064374 | 1x Everspring SM103 doorbell mod |1 Y-cam IP cam | various LUUP plugins |

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: if ( luup.is_night() ) then question
« Reply #4 on: June 08, 2011, 12:12:39 am »
Short answer.... no impact.

Whilst luup.timezone might not be populated, luup.is_night doesn't depend upon it to "work out" whether it's in the Sunset->Sunrise time window.  Most of the "luup." constructs are written directly in C, with no intermediate Lua dependancies, so it's not generally a problem as they can source the TZ data from elsewhere in your Vera system.

...unless, of course, you actually want the timezone offset value itself for some reason, then you'd be hosed.

Offline ballroller

  • Sr. Member
  • ****
  • Posts: 286
  • Karma: +0/-0
Re: if ( luup.is_night() ) then question
« Reply #5 on: June 08, 2011, 12:26:11 am »
Will implementing DAD have any effect on what is and isn't "night"?

According to the wiki (http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#function:_is_night) it returns true if time is between sunset and sunrise, which depends on where you set your location (http://wiki.micasaverde.com/index.php/Location).

Offline ballroller

  • Sr. Member
  • ****
  • Posts: 286
  • Karma: +0/-0
Re: if ( luup.is_night() ) then question
« Reply #6 on: June 09, 2011, 01:56:25 am »
Here is my dilemma. If I use the Lua code in my original post, the scene will NOT fire at night like it's supposed to. If I remove the Lua code from the scene, it works.

Any thoughts?

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: if ( luup.is_night() ) then question
« Reply #7 on: June 09, 2011, 03:10:27 am »
A long shot, you're not running an older MiOS version are you?  luup.is_night() wasn't in the original UI4 builds.  It was only documented in the Wiki in January 2011, so probably within that timeframe for it's addition to the MiOS Luup stack. 

If you're running a build from last yr, it may not have the command at all, and it would error out completely, and probably never fire the scene (day or night)

Do your logs show "errors" when this snippet of code fires?

ie. in /var/log/cmh/LuaUPnP.log (if you can SSH in)

Offline Henk

  • Hero Member
  • *****
  • Posts: 820
  • Karma: +3/-0
Re: if ( luup.is_night() ) then question
« Reply #8 on: June 09, 2011, 10:24:29 am »
Here is my dilemma. If I use the Lua code in my original post, the scene will NOT fire at night like it's supposed to. If I remove the Lua code from the scene, it works.

Any thoughts?

Same issue here, i added a "not" but lamp still goes ON even when day.
Could this be related to timezone settings variable of luup?

Before and after sunrise settings work fine!
| Vera2 @ UI4 1.1.1350 / 3.20 | Vera Lite @ UI5 | Vera 3 @ UI5 | 2x Merten  504519 | 1x Duewi  064374 | 1x Everspring SM103 doorbell mod |1 Y-cam IP cam | various LUUP plugins |

Offline ballroller

  • Sr. Member
  • ****
  • Posts: 286
  • Karma: +0/-0
Re: if ( luup.is_night() ) then question
« Reply #9 on: June 09, 2011, 10:41:10 am »
No. I just upgraded to .1245 in the last month or so.

How about a lesson in SSH'ing in? I have a putty client, but I don't know where to point it to.

A long shot, you're not running an older MiOS version are you?  luup.is_night() wasn't in the original UI4 builds.  It was only documented in the Wiki in January 2011, so probably within that timeframe for it's addition to the MiOS Luup stack. 

If you're running a build from last yr, it may not have the command at all, and it would error out completely, and probably never fire the scene (day or night)

Do your logs show "errors" when this snippet of code fires?

ie. in /var/log/cmh/LuaUPnP.log (if you can SSH in)

Offline Henk

  • Hero Member
  • *****
  • Posts: 820
  • Karma: +3/-0
Re: if ( luup.is_night() ) then question
« Reply #10 on: June 09, 2011, 10:51:49 am »
@ballroller

i created a SSH howto im the howto section of wiki.mios.com
everything you want to know is there!

Let me know of you have questions!
| Vera2 @ UI4 1.1.1350 / 3.20 | Vera Lite @ UI5 | Vera 3 @ UI5 | 2x Merten  504519 | 1x Duewi  064374 | 1x Everspring SM103 doorbell mod |1 Y-cam IP cam | various LUUP plugins |

Offline ballroller

  • Sr. Member
  • ****
  • Posts: 286
  • Karma: +0/-0
Re: if ( luup.is_night() ) then question
« Reply #11 on: June 09, 2011, 11:01:08 am »
I will check it out, thanks!

@ballroller

i created a SSH howto im the howto section of wiki.mios.com
everything you want to know is there!

Let me know of you have questions!

Offline ballroller

  • Sr. Member
  • ****
  • Posts: 286
  • Karma: +0/-0
Re: if ( luup.is_night() ) then question
« Reply #12 on: June 09, 2011, 11:07:52 am »
The wiki says to look for a password under "wifi pass" on the bottom of my Vera2.

I don't have anything that says "wifi pass" or anything with "pass" in it.

Nevermind. I have a HomeID code.
« Last Edit: June 09, 2011, 11:12:30 am by ballroller »

Offline mcvflorin

  • Administrator
  • Hero Member
  • *****
  • Posts: 1755
  • Karma: +11/-3
Re: if ( luup.is_night() ) then question
« Reply #13 on: June 09, 2011, 01:50:00 pm »
Could this be related to timezone settings variable of luup?
luup.is_night() is not related to the Timezone variable in user_data, but to the Latitude and Longitude variables in user_data.

Look in LuaUPnP.log for:
JobHandler_LuaUPnP::GetDayNight
or just:
GetDayNight

Code: [Select]
cat /tmp/log/cmh/LuaUPnP.log | grep -i 'GetDayNight'
You may want to enable verbose logging and leave it on for a while, so that the function will execute. Logging on a memory stick highly recommended.
Code: [Select]
VerboseLogging enable
Don't forget to disable verbose logging afterwards:
Code: [Select]
VerboseLogging disable