SunTracker plugin

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

SunTracker plugin

Post by krambriw » Tue Apr 22, 2008 10:34 am

Dear All,
This version of SunTracker is no longer supported. I have made a newer version with additional functionality that you will find here:

http://www.eventghost.org/forum/viewtop ... f=10&t=982

Please use that topic for discussions instead

Best regards, Walter



Hi,

Based on the same basic ideas as my old script, this is a useful little plugin if you need a scheduler that follows the sunrise/sunset.

First of all, all credits to Bartman, I have based this one too on code and structure from his Timer plugin.

I took it as a little challenge to re-work my script "SunRiseSet" into a plugin.

With this you could for instance fully automate your outdoor lights on your house, in your garden or park if you are lucky to have one. For sure its most useful for controlling lights and with the offset you can also control your indoor lights like I do myself. Maybe I should call the mayor, we could tune the whole downtown...and save some energy too...


I use radio controlled (RF) outlet switches, but basically you can control anything that is supported by EG, just copy and paste the event name in a macro with actions.

Some words about the settings as seen in the picture:

The first 3 fields for tracker and event names are rather obvious.

The longitude and latitude fields are needed to calculate the sunset/sunrise at your location.

For each daytype you have 3 time settings. Write them in format "hhmm" like "1830".

- "Night OFF" means any time between 0001-0559 when you want something to be turned OFF
- "Morning ON" is the time in the morning from 0600-1759 (long morning, yes) when you want
something to be turned ON
- "Evening OFF" is the OFF time in the evening starting from 1800-2359

A typical use-case could look like this

During weekdays, Monday through Thursday, it would be that
- the outdoor lamp is turned ON every morning at "0600"
- it is then turned OFF at sunrise
- it is turned ON again at sunset
- finally, its turned OFF later in the evening, like "2300"

On Friday evenings it would not be turned OFF, instead this happens Saturday night at "0200" (because the kids always arrives home much later during weekends)

For Saturday we do not turn ON the light at all in the morning, everybody is sleeping anyway...Later in the evening, it is turned ON at sunset. The same procedure as for Friday, its turned OFF at "0200" Sunday night.

On Sundays, finally, the same morning and eveing procedure as during Saturdays wih the exception that the lights are turned OFF in the evening at "2300".

During Vacation when the house is empty and you are dancing in Ibiza, another pattern could be applicable...

I hope you got the basic idea behind. The picture below is configured accordingly

There is a checkbox where you can enable/disable the vacation override function. If checked,
all days will follow the vacation schedule.

Then there are public holidays. You have fixed ones and you have variable ones (that changes
every year). So this you need to maintain yearly.

The logic in handling holidays is as follows
- if today is a normal weekday and tomorrow is a holiday, use time settings for Friday
- if today and tomorrow are holidays, use time settings for Saturday
- if today is a holiday and tomorrow normal weekday, use time settings for Sunday


Some devices, especially radio controlled, needs sometimes the command to be repeated. The setting for this is called bursts, here you define how many "copies" of the event you like to create when turning ON or OFF.

Some transmission devices also need a short delay between the transmissions. So there is also a setting for that.

Also it makes no sense to turn on lights if they anyway are going to be turned OFF shortly. Here you have a setting where you define the minimum ON period left to be required.

You can decide if you want the devices to be synchronized or not. This means that if by accident, someone turns a light OFF when its supposed to be ON, it will be turned ON again
at the next synchronization. The interval is also configurable.

If you like, you can specify an offset in minutes for ON/OFF events. A negative offset, as example -45, results in that the ON event is created the specified number of minutes (in this example 45 minutes) BEFORE the actual sunset happens.

The OFF event will occur the same amount of minutes AFTER the actual sunrise. This function is much appreciated when you like to control indoor lights since it's normally getting a bit darker earlier inside than outside.

A positive offset works the reverse way. It creates the ON event specified number of minutes AFTER the actual sunset. The OFF event will occur the same amount of minutes BEFORE the actual sunrise. This function can be used in cases where you think that there is still enough light from the sun also a period of time after the actual sunset and before the sunrise. It depends on your actual location.

Finally, you can decide if you like to have an entry printed in the log window for each loop execution.

Talking about log, in a separate directory, "Log", you find a logfile in html-format holding the on off actions

To make things happen, just do as normal, finalize your settings, create an event with the same name in any macro together with actions.


Best regards, Walter
SunTracker.jpg
Attachments
SunTracker_22.04.2008.zip
(61.05 KiB) Downloaded 389 times
Last edited by krambriw on Mon Mar 16, 2009 10:15 am, edited 1 time in total.

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: SunTracker plugin

Post by krambriw » Fri Apr 25, 2008 10:40 am

A little bug in first version :oops:

Here is the update
Attachments
SunTracker_28.04.2008.zip
(61.4 KiB) Downloaded 405 times

vuego
Experienced User
Posts: 70
Joined: Wed Jan 17, 2007 9:22 pm
Location: Sweden

Re: SunTracker plugin

Post by vuego » Sat May 10, 2008 6:21 pm

Hey krambriwm thanks for this plugin. It's much appreciated since the script was kinda unstable for me.

However I'm having trouble understanding how to use it. I've added the SunTracker Plugin and a SunTracker Action in Autostart. When starting EventGhost I get the message "Today is Saturday. Sunrise will be at 0458 and Sunset at 2118". Finally I disabled the "Log only assigned and activated events" checkbox. Now I'd expect an event to show up in the log at 21:18 which I then could drag&drop on to my macro but it doesn't. I set the synchronization to 6 minutes so one event should show up every 6 minutes, right?

I also tried naming my macros same as Event Name in SunTracker Action and added an Event with the same name but still nothing.

Attached are my settings.
Attachments
sunupdown.png

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: SunTracker plugin

Post by krambriw » Sun May 11, 2008 6:58 am

Hello Vuego,

The plug-in assumes that it shall have the role to turn ON and turn OFF selected devices.

You have to define at least a "Morning ON" time, otherwise there will not be any event created. Since B2 is never turned ON, the plug-in never tries to turn it off.

If you put in a "Morning ON" time like 1130 (if you only need evening control because at 1130 the sun is already up and there will not be any turn ON event created), you should expect to see an event every 6 minute or so in the log with your current settings.

Following your example, B2 will be turned ON at sunset and turned OFF at sunrise the following day.

Playing with the time settings you can create many different patterns.

Best regards, Walter

vuego
Experienced User
Posts: 70
Joined: Wed Jan 17, 2007 9:22 pm
Location: Sweden

Re: SunTracker plugin

Post by vuego » Sun May 11, 2008 1:28 pm

Thanks! That works much better

I was planning to play with the On/Off timers once I got the sun up/down working. That's what I get for being too methodical :)

Here's one vote for including this plugin in the EventGhost download :idea:

fatboy
Posts: 4
Joined: Tue Aug 26, 2008 9:15 pm

Re: SunTracker plugin

Post by fatboy » Tue Aug 26, 2008 9:22 pm

Hi,
Sorry to ask but, how do I know "The first 3 fields for tracker and event names are rather obvious."

I don't get it :(
How do I know what to put in the "event name on and event name off"

It works if I run the macro but not in the suntracker

Please help
Best Regards
FB

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: SunTracker plugin

Post by krambriw » Thu Aug 28, 2008 2:12 pm

Hello FB, no problem, cool if you find a usage for it;)

I should maybe have been more accurat in my description what to put in the various fields;

As "event name ON" you should put in a name that is related to what its going to initiate and that is "unique" because this will show up in the log on the left side in EG. Like "My aquarium lamp ON". Then you have to link this event with an action (on the right side of EG) to make things happen. Linking can be done by drag and drop once the event shows up or you can type exactly the same name manually when you first create the event in the configuration tree on the left side.

The same for "event name OFF"

Once you done it correct, the "event ON" will be fired and shown in the log at sunsets. In the same way the "event OFF" will be fired at sunrises.

With this configured correct it should work. If the macros are working fine, its just the matter of triggering them

In my test sample below, my event names are simply "Turn ON" and "Turn OFF" which is normally not enough unique,., I would recommend you to give them a more descriptive name

Best regards, Walter
Attachments
Image2.jpg
Image2.jpg (14.16 KiB) Viewed 10455 times

fatboy
Posts: 4
Joined: Tue Aug 26, 2008 9:15 pm

Re: SunTracker plugin

Post by fatboy » Thu Aug 28, 2008 5:27 pm

HI!
Tnx for the information :)

but I didn't get it to work :S

I tied to add an event but when I did (look at the screen shoot)

What did I do wrong?

eg
ver 03.6.1449
svn 458

windows 2003 server

Best Regards
Fredrik Svensson
Attachments
Screenshot-192.168.0.10 - Terminal Server Client.png

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: SunTracker plugin

Post by krambriw » Thu Aug 28, 2008 6:03 pm

Hi again,

It seems something goes wrong with EG itself....

I have not tried running it in Terminal server, don't know if this could be the reason

Besides, if you look at my picture and compare, you can see that you don't have configured any events the same way as I have.

But the problem starts already earlier when EG starts

Have you tried it in another PC running it directly in the OS?

Also, my picture was ment to show you how the macros needs to have an event and an action

You also have to add an action for the SunTracker plugin. You should see a setup like the earlier screenshots above

Best regards, Walter

PS Just tested with 1449 as well, works fine for me, no change

fatboy
Posts: 4
Joined: Tue Aug 26, 2008 9:15 pm

Re: SunTracker plugin

Post by fatboy » Thu Aug 28, 2008 7:09 pm

Hi!
Tnx again :)
Ok I will try working on it :)

BR
FatBoy

ja71
Posts: 5
Joined: Fri Sep 05, 2008 3:36 pm

Re: SunTracker plugin

Post by ja71 » Fri Sep 05, 2008 3:50 pm

Hello!

I have some problems getting started. I don't understand how to combine the plugins to get it working. I use Tellstick as my transmitter.
I would like to combine Suntracker with manual on/off times for some devices. In total I have 12 receivers.

The first step I understand...

1. I add the modules "Suntracker" and "TellStick" to Autostart.

...after this I am stuck :(

What should I do next? Add a separate Suntracker for each device I have? How do I combine Suntracker with the TellStick plugin? Do I need one event for ON and one for OFF? Should I put the Tellstick or Suntracker on the toplevel in the tree?

Please, help me getting started...

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: SunTracker plugin

Post by krambriw » Fri Sep 05, 2008 6:07 pm

Hi ja71,

Yes, you are thinking in the right way....

Add the plug-ins themselves as you have done (one for Tellstick and one SunTracker)

Then you right-click on the SunTracker plug-in and create an action (one for each receiver if you need different settings for each)

You will then get a setting dialog where you enter your data like the name of the action, your geographical position (to make it possible to calculate the sunrise/sunset where you live), the name of the events that is going to be generated when the action triggers for ON and OFF...and a lot of other settings. Look earlier in this thread and you will see a typical setting dialog.

Next step will be to create macros, actions and events for the Tellstick. Events must have the same names as you used above in SunTracker dialog

One macro can be used to trigger several receivers even if they have different adressing so you just create the Tellstick macros, add the actions you need and give the events the same names for all. If you need different settings for some, you have to create another SunTracker action. In the picture below you can see an example. I have added a delay between the Tellstick transmissions

Hope this helps a bit on your way, you are welcome with new questions

Best regards, Walter
Image1.jpg

ja71
Posts: 5
Joined: Fri Sep 05, 2008 3:36 pm

Re: SunTracker plugin

Post by ja71 » Sat Sep 06, 2008 8:01 am

Hi Walter!

Thanks a lot for a good description!!! Now the picture is getting much clearer. :D

I don't think I had figured this one out myself... :oops:

Best regards
/Jorgen

riksvag
Posts: 7
Joined: Mon Aug 18, 2008 7:06 pm

Re: SunTracker plugin

Post by riksvag » Tue Sep 09, 2008 7:10 pm

Hi all,

I've successfully been using suntracker for some time now, however I've run in to problems. I'm getting the following errors:

00:00:01 Today is Monday. Sunrise will be at 0614 and Sunset at 1933
00:00:01 Today is Monday. Sunrise will be at 0614 and Sunset at 1933
06:00:01 Exception in thread SunTrackerThread:
06:00:01 Traceback (most recent call last):
06:00:01 File "threading.pyc", line 486, in __bootstrap_inner
06:00:01 File "C:\Program Files\EventGhost\plugins\SunTracker\__init__.py", line 1033, in run
06:00:01 File "C:\Program Files\EventGhost\plugins\SunTracker\__init__.py", line 709, in CheckMorningLightOn
06:00:01 File "C:\Program Files\EventGhost\plugins\SunTracker\__init__.py", line 446, in MorningLightON
06:00:01 NameError: global name 'iMinOnPeriod' is not defined
06:00:01

I've two suntrackers, both to set my lamps to go on 0600, 10 minutes lights at least. One tracker is +-0 offset (outdoor), and one is -45 minutes (indoor). Neighter of them works in the morning, and today (and since a few days ) the outdoor lamps didn't go on.

Any ideas?
Attachments
untitled.JPG

fatboy
Posts: 4
Joined: Tue Aug 26, 2008 9:15 pm

Re: SunTracker plugin

Post by fatboy » Wed Sep 10, 2008 7:59 pm

HI,
I finally got almost everything working, only one thing left ... if I want to turn off the lights after 2359 it dont work
I have used "Night off" but it wont turn off my lights :S
any suggestions?

BR
Fatboy

Post Reply