Earthtools sun forecast

8 replies [Last post]
allanayr
Offline
Ayr, United Kingdom
Joined: 25 Sep 2011

Does anyone use the sample script for determining sunrise/sunset?

I've installed this script into my plugboard directory to implement sunset light switching as an alternative to the IFTTT + twitter version which I have used up to now.

I've changed the Lat/Long to (roughly) my home location and set it running. I've calculated the sunrise/sunset times and also referenced them from wuderground:

http://www.wunderground.com/cgi-bin/findweather/getForecast?query=55.507...

This gives sunrise /sunset of 7:37am / 5:27 pm which agrees with my calculated times.

The applet returns sunrise /  sunset times of sunrise=08:13:57 sunset=16:59:34 and the web page set to auto gives sunrise=09:13:57 sunset=17:59:34 for Prestwick airport. Neither of these times seems to have any relationship to the actual sunrise and sunset times.

I can, of course, just fiddle the Lat/Long to give a more acceptable answer but ........

Anyone else encountered this problem?

 

mark_baldwin
Offline
Blackburn, United Kingdom
Joined: 19 May 2012
earthtools.org down

Just had plugboard stop with this log

lua: /usr/share/lua/5.1/pl/xml.lua:619: attempt to perform arithmetic on local 'j' (a nil value)

stack traceback:

        /usr/share/lua/5.1/pl/xml.lua:619: in function 'parser'

        /usr/share/lua/5.1/pl/xml.lua:86: in function 'parse'

        /etc/plugboard/sunForecastApplet.lua:40: in function 'callback'

        /usr/share/lua/5.1/xap/init.lua:180: in function 'dispatch'

        /usr/share/lua/5.1/xap/init.lua:132: in function 'fun'

        /usr/share/lua/5.1/pl/List.lua:392: in function 'foreach'

        /usr/share/lua/5.1/xap/init.lua:130: in function 'process'

        /etc/plugboard/plugboard.lua:68: in main chunk

        [C]: ?

It seems www.earthtools.org is down at the moment which sends back a 404 error and thus breaks the xml parsing

brett
Offline
Providence, United States
Joined: 9 Jan 2010
I guess the request should

I guess the request should also get the status code and if this is not 200 (sucess) then just bug out.

   local xmlstring,statuscode = http.request(url)
   if xmlstring == nil or statuscode ~= 200 then return end

!= is C
~= is LUA  Why oh why did they did make up yet another not equals token set.

Brett

allanayr
Offline
Ayr, United Kingdom
Joined: 25 Sep 2011
Yep it crashed my plugboard

Yep it crashed my plugboard this morning too, caused me a bit of grief as I'm 2500 miles from home doing everything by remote control. It's supposed to be switching lights on while I'm away!

I'll leave it a few hours to see if it comes back up again and set up a cron schedule if it doesn't. 

Thanks for the heads-up Mark. 

mark_baldwin
Offline
Blackburn, United Kingdom
Joined: 19 May 2012
~= or !=

Brett

You do have to wonder why they do that sometimes. Is it just for sheer awkwardness or have they never used another language? 

The same is true for many of the syntax changes between one language and another.

I guess they want to make a stand, put their own stamp on it :)

 

Allan

It looks like it's still down so I have defaulted my 'daytime' to no

Mark

allanayr
Offline
Ayr, United Kingdom
Joined: 25 Sep 2011
Thanks Mark, I think I'll

Thanks Mark, I think I'll just set a cron to deal with it. The really annoying thing is that I ran it for 3 months before leaving to demonstrate to SWMBO that it was reliable, it never missed a beat. Now, within a few days of leaving it's gone belly up! All designed to make fools of us. :-(

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Alan did you see my comment? 

Alan did you see my comment?  Its a two line code change to fix and when earthtools come back up the applet will kick back into gear.

Brett

allanayr
Offline
Ayr, United Kingdom
Joined: 25 Sep 2011
Thanks Brett, I saw that,

Thanks Brett, I saw that, unfortunately I can't risk sending more than one "on" pulse or the lamp goes into dimming mode, so I'll ditch the earthtools route and go with a cron until I'm back. 

mark_baldwin
Offline
Blackburn, United Kingdom
Joined: 19 May 2012
Earthtools back up

Earth tools came back online sometime over night.

Hardware Info