Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

SunTracker - with moving ghost

Questions and comments specific to a particular plugin should go here.
Angus_MacGyver
Posts: 3
Joined: Tue Jun 12, 2012 12:00 pm

Re: SunTracker - with moving ghost

Post by Angus_MacGyver »

Oh, thanks.

I now entered a location ID like GMXX1234

Now I get an similar error:
17:47:02 Fehler in Befehl: "SunTracker: GetCurrentCondition"
17:47:02 Traceback (most recent call last) (1610):
17:47:02 File "C:\Program Files (x86)\EventGhost\eg\Classes\ActionBase.py", line 170, in CallWrapper
17:47:02 return self(*args)
17:47:02 File "C:\Program Files (x86)\EventGhost\plugins\SunTracker\__init__.py", line 5037, in __call__
17:47:02 return self.plugin.weather_data['condition']
17:47:02 TypeError: 'NoneType' object is unsubscriptable

Only the line an the error in __init__.py has switched to 5015...
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: SunTracker - with moving ghost

Post by krambriw »

That is not a correct format,

For Munich it is 676757 like in this url

http://weather.yahoo.com/germany/bavaria/munich-676757/
Angus_MacGyver
Posts: 3
Joined: Tue Jun 12, 2012 12:00 pm

Re: SunTracker - with moving ghost

Post by Angus_MacGyver »

OK, thank you. Now it works... :D
User avatar
Saxtus
Posts: 42
Joined: Wed Jan 02, 2013 3:37 am
Location: Athens, Greece
Contact:

Re: SunTracker - with moving ghost

Post by Saxtus »

I've decided to give a try to the Suntracker events generator dialog instead of generating and polling the weather events then querying their status (that btw, works just fine, but generates a lot of garbage on my logs and it's kinda counter-productive)
And I am failing miserably...

I get no events at sunrise/sunset according to what I've put at the "Event Creation Rules and Settings" section below:
Suntracking settings dialog.png
If I remove all the times from the "Day and Time Settings" I get only Suntracker OFF events every 30 minutes (as the interval I've set at the "Event Creation Rules and Settings" section)

What am I doing wrong?
Thanks in advance.
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: SunTracker - with moving ghost

Post by krambriw »

Hi,
Looks ok I think but there is a dependency to the plugin settings also. Could you please paste a screen-shot of the actual plugin settings as well?

BR
User avatar
Saxtus
Posts: 42
Joined: Wed Jan 02, 2013 3:37 am
Location: Athens, Greece
Contact:

Re: SunTracker - with moving ghost

Post by Saxtus »

Suntracker settings.png
Suntracker configuration tree.png
Suntracker configuration tree.png (8.78 KiB) Viewed 7358 times
And I've noticed that I get this on startup:
Suntracker startup error.png
User avatar
Saxtus
Posts: 42
Joined: Wed Jan 02, 2013 3:37 am
Location: Athens, Greece
Contact:

Re: SunTracker - with moving ghost

Post by Saxtus »

Generating the report here, solved the problem!

To take the middle screenshot of my last post, I've moved the SunTracker autostart actions to the top and that way found out what was causing SunTracker's errors:

Exactly before it was called (while it was at the bottom of my autostart actions), I was calling a macro that had an action "Find window" while searching invisible items too.
That takes time and it was making EventGhost to freeze for few seconds. It seems that EventGhost or your script didn't like that.

Now it's working just fine.
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: SunTracker - with moving ghost

Post by krambriw »

Great, nice to hear!

Best regards, Walter
rdgerken
Experienced User
Posts: 89
Joined: Fri Sep 21, 2012 7:41 pm

Re: SunTracker - with moving ghost

Post by rdgerken »

Walter,

My house gets a lot of sun in the evenings. I wanted to set up a macro that would close the shades automatically if the weather is sunny. Problem is, I think I would need to trigger 3-4 hours before sunset, when the weather is "Sunny". I have some script that gets the weather condition using SunTracker no problem, but I'm struggling to figure out how I can use the SunTracker plugin to give me an event 3-4 hours before sunset. Is this possible?

And now that I think about it... is it possible to check for "Sunny" over the course of those 3-4 hours? It's great if I can check once, and if it's sunny, move the shade - but let's consider the scenario where it's cloudy at the -4 hr mark, and then 1 hour later at the -3 mark, it's sunny. Almost like I'd need to find a way to check the weather continuously (as in every 10-15 minutes or something) in that time frame, as opposed to just checking one time. But, I'd like to know if it's possible to do it both ways.

Thanks!

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

Re: SunTracker - with moving ghost

Post by krambriw »

Interesting and challenging topic...yes it is possible

I have a similar very personal solution in place, using weather condition, sunrise, current light level, time scheduling and calendar. In my case I run the awnings down 2 hours after sunrise if light, weather and calendar conditions are met. Then they are always run up at 13.00 (1.00 pm) since there will be shadow on that side in the afternoon (facade is in south/east). If any condition is not met, the same will happen earlier after a certain configurable delay (to avoid frequent up/down movements).

Let's for the moment just break down your use case (or business requirement) into smaller user stories:

- close if sunny (or other configurable weather conditions)
- close if sunset time - current time is equal or less to 3-4 hours (configurable)
- if both conditions are met, run shades down, else run them up
- (check the conditions at a configurable interval)

To make it as simple as possible to start, I think it can be managed with a python script being triggered by the weather condition event sent every minute from the SunTracker plugin.

In the first version of the script, we would need to:
- capture the weather condition event
- retrieve the sunset time and current time
- calculate the difference between and if less than 3-4 hours
- if conditions are met, generate an event to run shades down, else up

In the next, I will show you a python script sample that will work accordingly, just need some more time to write (and test) it...

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

Re: SunTracker - with moving ghost

Post by krambriw »

Here is a script to start with

1) Create a simple python script macro as in the picture below. Copy & paste the weather condition event generated every minute by the SunTracker plugin (if not enabled, you have to do it)
Image2.jpg
Image2.jpg (3.2 KiB) Viewed 7312 times
2) Edit the python script and paste in the following code

Code: Select all

def CheckWeather(pload):
    cond = False
    if pload == 'Sunny':
        cond = True
    return cond


import time
#Check weather condition
wCondition = CheckWeather(eg.event.payload)
timeStamp = str(
    time.strftime("%H%M", time.localtime())
)
#Convert current time into minutes
ct_m = int(timeStamp[0:2])*60 + int(timeStamp[3:4])

ss_sr = eg.plugins.Suntracker.GetTimeFor_SunSet_SunRise()
ss_h = ss_sr[1].split('|')[1]
#Convert sunset time into minutes
ss_m = int(ss_h[0:2])*60 + int(ss_h[3:4])

t_diff = ss_m - ct_m

if t_diff < 240 and wCondition:
    eg.TriggerEvent("shades down")
else:
    eg.TriggerEvent("shades up")

It is written for closing the shades 4 hours before sunset if the weather condition is 'Sunny' (case sensitive)

After sunset, or if weather condition might change earlier, the shades will be moved up again

BestR Walter
rdgerken
Experienced User
Posts: 89
Joined: Fri Sep 21, 2012 7:41 pm

Re: SunTracker - with moving ghost

Post by rdgerken »

Walter,

Thanks so much for taking the time to show me how to do that! I will try it out.

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

Re: SunTracker - with moving ghost

Post by krambriw »

I think I over looked one thing. This part of the code needs to be

Code: Select all

if t_diff < 240 and t_diff > 0 and wCondition:
    eg.TriggerEvent("shades down")
else:
    eg.TriggerEvent("shades up")
BR
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: SunTracker - with moving ghost

Post by krambriw »

or maybe more elegant...

Code: Select all

if t_diff in range(240+1) and wCondition:
    eg.TriggerEvent("shades down")
else:
    eg.TriggerEvent("shades up")
rdgerken
Experienced User
Posts: 89
Joined: Fri Sep 21, 2012 7:41 pm

Re: SunTracker - with moving ghost

Post by rdgerken »

Thank you,

I made that adjustment, but I'm not sure what it does. :)

Also, I'm looking for condition = Sunny, but I noticed that my weather is being reported as "Fair" - even though there isn't a cloud in the sky...

I suppose I should match on either condition? I saw a list of conditions somewhere, I guess I'll just have to play around with that a bit. I saw someone else had a list of conditions where they wanted light, so maybe I could use that, and invert it?

Thanks again,
Ryan
Post Reply