Earthtools sun forecast

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.50…

Member for

14 years 5 months

mark_baldwin

12 years 7 months ago

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

Member for

16 years 10 months

brett

12 years 7 months ago

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

Member for

15 years 1 month

allanayr

12 years 7 months ago

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. 

Member for

14 years 5 months

mark_baldwin

12 years 7 months ago

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

Member for

15 years 1 month

allanayr

12 years 7 months ago

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. :-(

Member for

16 years 10 months

brett

12 years 7 months ago

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

Member for

15 years 1 month

allanayr

12 years 7 months ago

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. 

Member for

14 years 5 months

mark_baldwin

12 years 7 months ago

Earth tools came back online sometime over night.