HomeSeer Events Based on Moonrise/set?

I have a 90 gallon reef tank that I just bought a "moon light" for. Using HomeSeer, I would like to automate the light to mimic the moon by turning on (moonrise), setting dim level, (illumination based on moon phase) and turning off (moonset).

I've googled-up all sorts of programs and sites but have no clue how to capture the information, import it and put it to use. I suck at programming.

Eventually, as $$ allows, and I add a data logger with temp/pH probes and the like, it would be cool to display a live picture of the tank with water parameters on an overlay using MainLobby ---- AquariumLobby!

I have found controllers available for purchase that do just what I want but I'd like to use this as a way to learn. Can anyone point me in the right direction?


Thanks Rupp,

I did a search at HomeSeer but obviously didn't look back far enough ;)

I downloaded the script but I really don't know what to do with it. I have very little experience with this kind of thing so any basic help is appreciated. In the meantime I'll see what I can mess up!!

Thanks again for your help,,
I added a sub main in the script. In this sub it lists 3 virtual devices that you can create and once run this script will populate the devices with MoonRise, MoonSet, and Status (up or down). When you create your events make sure you edit them in the script. I would recommend creating a event that is triggered once a day to run the script to update these values.


    5.7 KB · Views: 38
I started writing this when I read the post just before Rupp's. I left for a bit, and when I came back and finished it, I noticed Rupp also created another version. So this may be a duplicate, or maby you can use something from this....

This script, will calculate the phase of the moon and then send the proper dim command to a light (Your aquarium light I would immagine).

For instance if it is a quarter moon, this script will set the brightness to 25% for the light being controlled.

I hope this is of some help.


    907 bytes · Views: 16
I just downloaded and looked at the script that Rupp found, between that one, and the small one I put together, I think they will do exactly what you are looking for!

I edited my script from above, to use the moonrise & set from the virtual devices created by the script Rupp uploaded. The one above did not take this into concideration. If the moon was not actually up, it would still set the device to the dim level depending on the phase of the moon.

First get the one that Rupp uploaded and put it in your scripts directory. You will then need to create 3 virtual devices to hold the value's. By default it uses M1,M2 & M3.

Now create an event to run that script, say on the hour. This will update the devices with the current status of the moon.

Now copy this script attached to your scripts folder, and create an event to run it say 5 minutes after the hour. This script depends on the status of the moon from Rupp's.

When all is said and done, the attached script will look to the device value stored in M3, to see if the moon is actually up or not. If it is, then the light will be dimed to the appropriate brightness, depending on the actual phase of the moon. For instance if it is a 3/4 moon, the light will be dimmed to 75%. If the moon has set, it will then dim the light to 0% until it detects that it has risen again, and will dim it again, based on the correct phase of the moon.

Please keep us posted and let us know if its working the way you wanted!


    847 bytes · Views: 15

Thanks for all your efforts. Rupp too!!

I just started working with these scripts. I created the three virtual devices, M1,2,3, have the scripts recurring every hour and checked my event log. I get an error:

Script error in file: MoonrRiseSet.txt: 13:Type mismatch: 'cdbl' in line 57

Looking at the script, it looks like it has to do with finding the lat/long stored in HomeSeer?

Let me know if you need more info.


Sorry for the delayed reply, just got back tonight from EHX in Orlando.

I will look into it and see if I can figgure it out, I know nothing about that script, but I will see....

In the mean time, go into HomeSeer's options, and the Sunrise/Sunset tab, and see if your location is set. If so try changing it to West Palm Beach, FLorida (Thats where I am and I know it works with that). If it then works, or does not, it will be narrowed down to your location, or just not getting the values at all from HomeSeer.
Thanks for the reply. I have Homeseer set properly as I have events run based on sunset. As I type this, I'm wondering if it is how I have my location set that may be the problem. I entered my location from my GPS out to three places, for ex:
Latitude = 41.41.37. Perhaps I should just do two places (41.41) I'll try that and see.

Also, I think I see in that script that I can manually enter the location. Can I just comment out the part that looks in HomeSeer and enter the location?

I really haven't spent much time on this myself. Sometimes things like work get in the way.

Thanks for your help, and please don't put yourself out over this.

Finallly got around to trying this and I must say this is way cool. The problem I reported above was in fact the way I had my location entered in HomeSeer. Once I deleted the third number in the lat/lon everything worked just like you guys planned. Thank you both for your efforts, I really appreciate it.



I'm glad we could help you out! Is it working the way you wanted it to? You will probably have to put some sort of condition in the script that if it is daylight out (after sunrise and before sunset) to not have the light come on.

This was actually a good project/script, as I am now adapting it for a page on my site. It will display a large hi-res photo of the moon, in its current state, when the moonrise/set are, and working now on a graphical representation of where it is in the sky based on how long it has been up ect. It will "traverse the sky" as the moon travels through its azmith on the page.

You can check out a rough draft of the page on my HS site at: Just follow the link on the left to "My HomeSeer site". It is brand new, and havent even taken the time to create a "button" for it on the main page, its just a text link right now.

Take Care!

That web page is the best!! Nice photo of the moon phase. Did you get the photo from the USNO site?

My scripts seem to be working as planned. I have yet to get my moon lights to actually trigger on/off even though the Moonstatus shanges. I've used the device name as you mentioned in the comments. I'll do some troubleshooting when I can. I'm not at all good with scipting/programming, but I'd like to try to figure this out. When I get it all working I'll post a pic of the tank glowing in "moonlight".

Thanks again for all your help and I'm happy you were able to put this to work as well. Thanks to Rupp for the help also.


Edit: I beleive I found my problem. I had device name as Moon lights instaed of moon light.
Sorry for the delay in responding.

Actually I found an image that had all phases of the moon on one "sheet". It was a VERY nice Hi-Res image. I had to VERY painstakingly cut each moon out, and align them up and save each individual phase with the correct naming convention.

I also am JUST about finished with a "moon horizon thingy" ;). I created a night sky graphic, and an arch across it. It will then show the moon azmith in relation to the horizon. It is working 80% and still tweaking it a bit. It is a pain to calculate the time the moon has been up, in relation to if the rise was before or after midnight/noon, and then calculate how far past midnight/noon it is ect. Also I have noticed that the script from above, that sets the virtual devices for Moonrise,Moonset, and status, will sometimes not give the moonrise/set time. It even states in the script that this will sometimes happen when there is no moonrise for a perticular day. That honestly just dosent make sence to me. It comes up EVERY 9-12 hours or so without fail. So why the author states that it sometimes does not, is beyony my grasp.

When it works right, it is pretty kewl to look at the graphic, and then go out side and see the moon is actually the same distance from the horizon that the graphic showes.

You can check it out on my page at the same link above if you want.

I put the moon thing on the back burner, as I just TOTALLY re-did my lighting control page. It came out pretty kewl! When a room is selected, it will show an image of that room on the right side of the page, and the lower portion of the page changes to show the devices in that particular room. It's done with Iframes, and I can tell you it was no fun trying to figgure out how when something was clicked, to change to differnet areas of the page!