I would sugest sunrise/sunset information be made available as part of a standard set of functionality to do with time.
An example of how lighting system use sunrise/sunset is to turn on the lights ten minutes before sunset the advantage being you set in once and it done for the year and works better than a light sensor.
I would imagine a lot of imp projects will be using time so it’d be nice to see it handled in a standardised way.
I have been playing with wolfram alpha and it can answer questions like these : sunrise today, london, uk
The API is oriented at displaying the results on webpages, i’m guessing parsing the results would be something best done in an agent and not the imp itself.
If you change your mind Hugo, perhaps add public holidays into the API, then you could save energy by having buildings that don’t heat up when no-one is due to be there and we could have Alarm clocks that know when to leave us alone!
Perhaps a simple (brand-able) portal is needed for consumers to set stuff like this
A PHP script could be written that gives the imp that info, but it would still need to be told the proper timezone. The timezone would have to be programmed on the imp, and the imp would need to query the PHP script at least once per day … or a CRON job on the webhost server posts to the imp at least once per day. Hopefully stuff like this becomes functions on the imp server as new features are developed.
I have a PHP script that uses a WOEID (where on earth id) and returns back sunrise and sunset times for the location of the WOEID. The PHP script itself uses Yahoo Weather API to get its information.
The hard part about a lot of the date/time issues is timezone and daylight savings time. The Yahoo Weather API takes care of all those issues at once. The PHP script can then return the two times in any format desired (12hr, 24hr, UNIX timestamp).
So we’re back to the imp again. The WOEID of the imp can be manually programmed, but if the the imp gets moved to a different location farther away, the sunrise|sunset times will no longer be correct.
Because PHP (on someone’s website) is being used, instead of that PHP script returning sunrise|sunset times, it could just return a 1 or 0 … 1=it’s daytime, 0=it’s nighttime. Let the PHP script do all of the time calculations based on the WOEID. The imp would only need to know if it’s light out or not.
If anyone wants to see the PHP script that uses a WOEID and returns a 1|0 back to the imp, let me know. Until the http agents are public (not in beta mode) it’s a bit more cumbersome because the planner nodes need to be used.
Hi mIseim,
I’m interrested in your php code. Have you finally suceeded in writing your code with the agents ? (I have read your post in the early beta section)
Thanks
I can send WOEID to the PHP script, I haven’t figured out yet how to get the result back to the imp. When I get that, I’ll post the whole thing. I’m going to change the PHP script to send back “d” or “n” for ‘daytime’ or ‘nighttime’. For some lighting control, I only need to know if it’s “n”. I don’t know how good the imp is at doing date/time calculations, so I’ll let PHP do that. I’ll post it later this evening on this thread.