Page 33 of 38

Re: SunTracker - with moving ghost

Posted: Thu Aug 28, 2014 5:47 pm
by TRIROG1
Hi Walter!

Is it possible to somehow get the sunrise and sunset times compensated by an set offset into a variable?

i'm thinking something like eg.plugins.Suntracker.GetTimeFor_SunSet_SunRise() but with current offsets?

Thanks!

Re: SunTracker - with moving ghost

Posted: Thu Aug 28, 2014 5:51 pm
by TRIROG1
krambriw wrote:Hi,
I assume you use the normal action for this where you have defined an offset of -20 minutes?

As I have understood from your description, the automatic function is working as it should, it was only that you made a manual override (you lowered the shutters manually even though the shutters normally would have been raised due to the automatic control)

What is happening is that when you restart the plugin, it will always send out the correct state it is supposed to keep. So in this case, you got the situation that the automatic adjusted the state back to the expected.

It is also they way I have made the logic and it will not be something I would like to change. If possible, we should try to solve it in a different way.

One possibility I am thinking of is to sequentially enable/disable the macros for the automatic function in such a way so that ones "raised", the next possible can only be "lowered"...

It is an interesting case, a bit advanced to begin, but with the flexibility of EventGhost, I think the following should work for you:
Image2.jpg
To save the actual settings so that it will be persistent and 'survive' a restart, each macro includes also the python command eg.document.Save()

Every time SunTracker generates an event that matches, the corresponding macro is executed and disables itself, enables the macro for the reverse operation and saves the changed configuration (to recover correctly from any kind of EG or PC restart)

Best regards, Walter
Thanks for the case... i solved it more basically ... i just check if the sun is up ... and since the shutters should raise 20 minutes before the sunset, the sun is allways up ... but if the EG restarts in the middle of the night ( due to a power failure or sth) the condition sun is up is False and the macro isn't executed ... baisc ... but it works ;)

Re: SunTracker - with moving ghost

Posted: Fri Aug 29, 2014 1:22 pm
by krambriw
Is it possible to somehow get the sunrise and sunset times compensated by an set offset into a variable?

i'm thinking something like eg.plugins.Suntracker.GetTimeFor_SunSet_SunRise() but with current offsets?
I think the available action 'SunTracker: Check if Sun will be down in X minutes: -20' would be what you are looking for

In a script you could check if True or False and use this for further processing

Code: Select all

print eg.plugins.Suntracker.IsSunDown(-20, 0)

Re: SunTracker - with moving ghost

Posted: Sun Aug 31, 2014 9:02 pm
by TRIROG1
Hey!

I knew about that one ... What i'm trying is to have an event time calculated in advance so i can display it on the web page ... Currently i'm displaying sun up and down times, but the event actually happens with a - 20 min offset so those times are inacurate ...

Re: SunTracker - with moving ghost

Posted: Mon Sep 01, 2014 6:49 pm
by krambriw
Well, yes, it is possible but you need to use a python script. The example below shows you how to. It is not so much EventGhost, more of python.

Best regards, Walter

Code: Select all

import datetime

#Get sunrise/sunset data from SunTracker plugin 
theSun = eg.plugins.Suntracker.GetTimeFor_SunSet_SunRise()

#Set your offset value in minutes
theOffset = -20

#Create datetime objects for sunrise/sunset times
sunUp = theSun[0].split('|')[1]
sunDwn = theSun[1].split('|')[1]
sU = datetime.datetime.strptime(sunUp, "%H%M")
sD = datetime.datetime.strptime(sunDwn, "%H%M")

#Calculate new times with the offset
sD_offset = (sD + datetime.timedelta(minutes = theOffset)).time()
if theOffset < 0:
    sU_offset = (sU + datetime.timedelta(minutes = abs(theOffset))).time()
else:
    sU_offset = (sU - datetime.timedelta(minutes = theOffset)).time()

#Now add code to format the results and add other logic
print theSun
print sU_offset
print sD_offset
#Some examples
sUp = str(sU_offset).split(':')
print sUp[0]+sUp[1]
sDn = str(sD_offset).split(':')
print sDn[0]+sDn[1]


Re: SunTracker - with moving ghost

Posted: Mon Sep 01, 2014 7:33 pm
by TRIROG1
Walter, thank you very much for this!


I've been playing around this all day trying to figure out the timedelta and time.strp commands, but didn't get it to work ... Didn't give up though...just ran out of play time :)

Thank you!

Re: SunTracker - with moving ghost

Posted: Tue Sep 02, 2014 5:06 am
by krambriw
Hi, good to hear,

Anyway, I think your suggestion is good so this will be a candidate for a new action. I will add it next time a make a new version.

If you have an idea and suggestion in what format you would like to have the result, I could provide that as return value from the action?

What is best?

- just return the datetime objects as they are like 06:07:00, 19:28:00
- provide them as strings in a list ['0607', '1928'] or in a dictionary {'SunUp': '0607', 'SunDown':'1928'}
- create events with payloads SunTracker.SunUpOffset: '0607 and SunTracker.SunDownOffset: '1928'

Best regards, Walter

Re: SunTracker - with moving ghost

Posted: Tue Sep 02, 2014 6:10 am
by TRIROG1
As far as i'm concerned i think it would be the best to simply return them the same way all the other times are returned, so one can simply manipulate the data in the same way as all the other time values in the Plugin ...

:)

Azimuth and Altitude available?

Posted: Thu Oct 02, 2014 10:16 am
by pubsfried
@Walter @krambriw
Walter,
first of all I wanna say thanks for yor plugin, great work!

I just started to work with EG and got my shutters (12 windows) running with macro, time dependent (FS20 radio controlled) and in combination with user intervention.

Now I want to control them depending on sun's azimuth and altitude (as shown on http://en.wikipedia.org/wiki/Azimuth ) , because some windows are in the shadow of a big tree, the balcony, neighbours house or other objects around the house depending on season. so this is the only way to maximize sun protection combined with maximum daylight in the rooms, or to open shutters in unused rooms to harvest solar energy thru the windows (combined with weather conditions, of course).

So my question is: is there a way to use sun's azimuth and altitude with suntracker?
A little example on how to use this variables would be nice.

Many thanks in advance!
Michael

PS: I did something similar to calc sun's azimuth and altitude already in Excel/VBA, in case someone needs it send me a PM!

Re: SunTracker - with moving ghost

Posted: Thu Oct 02, 2014 11:29 am
by krambriw
@Michael

It is not possible in the latest version of the plugin but it is a good suggestion. With python there are however almost always a possibility to do more than what is implemented in each and every plugin (as long as it is supported in some of the used libraries).

The SunTracker is depending on Sun.py, made available to the public by (c) Paul Schlyter. And the module provides more functions than what I have used, maybe also what you are asking for.

If you are willing to create a macro with a python script, you could create an event self rather easily. I give you here an example if this is what you could use (Returns the angle of the Sun (RA), the declination (dec) and the distance of the Sun (r) for a given day d.)

1) Copy the file Sun.py to the '\lib26\site-packages' folder

2) Add a macro with python script and copy & paste the below sample. Insert your latitude and target date

3) Execute it

Code: Select all

import Sun
a = Sun.Sun()
b = Sun.Sun.solar_altitude(a, 59.4287, 2014, 10, 2)
c = a.daysSince2000Jan0(2014, 10, 2)
d = a.sunRADec(c)
eg.TriggerEvent(str(b),'eventual payload','Sun')
eg.TriggerEvent(str(d),'eventual payload','Sun')
I do not know if this helps you, there are also other functions available in Sun.py that you can reach in a similar way.

BestR Walter

Re: SunTracker - with moving ghost

Posted: Thu Dec 04, 2014 9:34 pm
by DarkCinema
Hi All,

I currently using this great plugin to activate my HUE lights at the sunset time. Triggered by the default plugin action xxx.sunset. Since I am a noob in Phyton adn Eventghost I need some help to activate the lights earlier depending on the weather conditions. Can someone hand me an xml example file how to set this up in Eventghost?

Re: SunTracker - with moving ghost

Posted: Sun Nov 22, 2015 1:27 pm
by krambriw
New version available:

After having problems with YAHOO! Weather, the plugin is now instead utilizing Weather.com to get current local weather conditions. To find your location ID, browse or search for your city from the Weather.com home page(http://weather.com) The weather ID is in the URL for the forecast page for that city. For example, if you search for New York, the forecast page for that city is http://www.weather.com/weather/today/l/USNY0996:1:US. The location ID is USNY0996:1:US.

PLEASE NOTE: Always take a copy of your local weather_conditions.py file before you upgrade if you have made any modifications to it and copy it back afterwards.

To upgrade, it is very important to follow the steps below in the specified order.

1) When EG is running current version, disable the SunTracker plugin and all SunTracker actions so that they all stops
- save and exit EG

2) From the link below, fetch the latest version of the plugin (if you have it installed earlier you only need to replace __init__.py and pywapi.py)
- start EG again

3) Now configure the SunTracker plugin with the location ID you picked from Weather.com (see picture below). When finished, click ok, then enable the plugin so that it starts.

4) Now for each action, configure each of them by opening them and clicking ok

5) Enable each of the actions

6) Open the settings for the plugin again and check that they are all running
- save the configuration

7) You are done!
Skärmklipp.JPG
Skärmklipp.JPG (9.81 KiB) Viewed 5587 times

Re: SunTracker - with moving ghost

Posted: Sun Nov 22, 2015 9:44 pm
by SupahNoob
Walter, I've not ever used your plugin before ... is it the one that is native to EventGhost? What is its current version? Or did you forget to attach the updated zip?

Thanks,
- SN

Re: SunTracker - with moving ghost

Posted: Mon Nov 23, 2015 5:23 am
by krambriw
Walter, I've not ever used your plugin before ... is it the one that is native to EventGhost?
Yes, that is so, that is my plugin.
What is its current version?
This updated one is some versions newer, not really sure which version is included in the EG setup.
Or did you forget to attach the updated zip?
I stopped attaching zip's to postings a while ago, you find the latest versions of all my plugins via the link to my Apache server below in my footer.

Re: SunTracker - with moving ghost

Posted: Thu Nov 26, 2015 4:49 pm
by Old Bear
Hi Walter,

Love the plugin, but I notice that since the change to weather.com I can't get a return from Get CurrentCondition. It all worked fine till the last chage.

EG log shows:

16:48:04 Error in Action: "SunTracker: GetCurrentCondition"
16:48:04 Traceback (most recent call last) (1710):
16:48:04 File "C:\Program Files (x86)\EventGhost\eg\Classes\ActionBase.py", line 170, in CallWrapper
16:48:04 return self(*args)
16:48:04 File "C:\Program Files (x86)\EventGhost\plugins\SunTracker\__init__.py", line 5417, in __call__
16:48:04 return self.plugin.weather_data['condition']
16:48:04 KeyError: 'condition'

Any idea where I'm going wrong? Thanks.