Introduction
This post has no lollipops or rainbows, but I couldn't think of a better title. Today I was experimenting with another binding in OpenHAB. This one is called Astro, and it provides information about the suns position throughout the day. This means you can know exactly where the sun is located in the sky relative to your home. It also provides the basics like sunrise, noon, and sunset times. So, you might ask,
"Why would I care about the position of the sun?"
If you were automating your blinds, this tool would be extremely powerful. You can set rules in OpenHAB to automatically close your blinds when the sun would be shining through windows and heating your home. This binding makes me wish automating blinds was part of my project, but I doubt my landlord would approve. I have settled for these basic quantities added to my OpenHAB UI:
- The time of sunrise
- The time of noon (solar)
- The time of sunset
- The suns position (Azimuth and Elevation)
It may be interesting, later, to perform some calculations with these numbers, but for now I'll settle for the numbers.
Starting Astro
Once again, open up that openhab.cfg file and make the following edits:
################################# Astro Binding ####################################### # # The latitude astro:latitude=NN.nnnnnn # The longitude astro:longitude=-NN.nnnnnn # Refresh interval for azimuth and elevation calculation in seconds # (optional, defaults to disabled) astro:interval=600
astro:interval is the number of seconds between updating the values. Also, you may be wondering what your position's latitude and longitude are. Load up Google Maps. Type in your address and let Google find your house. You can either stay in map view or switch to Earth view, which ever you prefer. Simply click anywhere on the map, and you will see the latitude and longitude in a small box such as below:
Hopefully you have been able to set your latitude and longitude correctly. Now restart OpenHAB (I.e. exit and run start.sh again)
Adding the Items
I added the following values to the items file:
Number Azimuth "Azimuth [%.2f]" {astro="type=AZIMUTH"} Number Elevation "Elevation [%.2f]" {astro="type=ELEVATION"} DateTime Sunrise_Time "Sunrise [%1$tH:%1$tM]" {astro="type=SUNRISE_TIME"} DateTime Noon_Time "Noon [%1$tH:%1$tM]" {astro="type=NOON_TIME"} DateTime Sunset_Time "Sunset [%1$tH:%1$tM]" {astro="type=SUNSET_TIME"}
Modifying the Sitemap
I also added this frame to my sitemap:
Frame label="Astro" { Text item=Azimuth Text item=Elevation Text item=Sunrise_Time Text item=Noon_Time Text item=Sunset_Time }
Results
After all is said and done, here is the result:
Almost forgot! Wondering what the heck Azimuth and Elevation are anyway? Azimuth is the angle from NORTH to the sun's position moving clockwise and Elevation is the angle from the horizon to the sun. Elevation is simple, but to understand azimuth picture a clock face where 12 o'clock is NORTH. This position corresponds to an azimuth of 0 degrees. Three o'clock would be an azimuth of 90 degrees, six o'clock would be 180 degrees, and so on.