Page 14 of 38

Re: SunTracker - with moving ghost

Posted: Tue Aug 07, 2012 5:06 am
by Livin
Hi Walter,
Just installed the latest version... so far, so good. I have not yet put it through its paces... I'll do that this week and let you know if I find anything. Your latest additions make it sooo flexible - it rocks.

Re: SunTracker - with moving ghost

Posted: Sun Aug 12, 2012 7:44 am
by holle75
Hi Walter, i┬┤m back from holidays and according to the log everything worked like it should. Thank you again for your patience and your work!

.... can i also use the newest version you worked on with livin? seems there are some new very interesting "switches" to play with ;)

best regards

H.

Re: SunTracker - with moving ghost

Posted: Sun Aug 12, 2012 7:52 am
by krambriw
Yes, sure, you can use that version instead, I will soon make that one official since also those changes seem to work fine.

Best regards

Re: SunTracker - with moving ghost

Posted: Sun Aug 12, 2012 11:01 pm
by Livin
Yeah... LOVE the new version... working flawlessly for me! Walter... thank you again and again!

Re: SunTracker - with moving ghost

Posted: Mon Aug 13, 2012 9:46 pm
by holle75
Hi Walter, today (right now) i started EG again. I think i never restarted EG when the sun was already down the last tests.....

i got an error in "iphone coming home check" script we worked on before

Code: Select all

23:37:37            Traceback (most recent call last):
23:37:37              Python script "10", line 4, in <module>
23:37:37                bSunIsDown = eg.plugins.Suntracker.IsSunDown(-60, 60)
23:37:37              File "C:\Programme\EventGhost\plugins\SunTracker\__init__.py", line 4336, in __call__
23:37:37                ssMins = self.CalcNbrOfMinutes(self.plugin.csSS)
23:37:37              File "C:\Programme\EventGhost\plugins\SunTracker\__init__.py", line 4292, in CalcNbrOfMinutes
23:37:37                iHour = int(s[0:2])
23:37:37            ValueError: invalid literal for int() with base 10: ''
any ideas?

ah, the code:

Code: Select all

eg.plugins.Suntracker.SetMovingGhostOFF()
print "GHOST ist OFF"
if eg.globals.IphoneHolgerOUT == "True":
    bSunIsDown = eg.plugins.Suntracker.IsSunDown(-60, 60)
    if bSunIsDown:
        eg.TriggerEvent('LICHT.licht ON')
    else:
        print "Kein Licht ON weil Tag"
else:
    print "Kein Licht ON weil Holger ist zu Hause"
EDIT: i figured out, that this is only happening when the iphone logs in during initialisation.

Re: SunTracker - with moving ghost

Posted: Tue Aug 14, 2012 5:58 am
by krambriw
Dear Holger, thank you, I need to block this somehow because what is happen is that the plugin is asked too early as you have noticed.

Another thing I have also seen happening lately is that when I request weather data from Google, there is something nothing returned due to timeouts or whatever. So I am also improving this part and it is now working fine with retries in my test here (maybe there is no problem for other locations but anyway...)

Best regards, Walter

Re: SunTracker - with moving ghost

Posted: Tue Aug 14, 2012 7:09 am
by piert
Another thing I have also seen happening lately is that when I request weather data from Google, there is something nothing returned due to timeouts or whatever
Aha!, this probably explains the rather vague "URL Error" in my Eventghost log that comes up at irregular intervals (maybe every 10-15 minutes on average).

Re: SunTracker - with moving ghost

Posted: Tue Aug 14, 2012 2:05 pm
by krambriw
Yes, exactly, in my developer version it is still coming but after one or more retries it succeeds. I'll check if I can remove the URL error message now as well.

BR

Re: SunTracker - with moving ghost

Posted: Thu Aug 16, 2012 10:52 am
by krambriw
I have uploaded a new version with all the beta functions and new methods to handle the weather data collection better. It also fixes the problem Holger found. Getter actions will not work (and not create a crash) when the plugin starts up (during initialization).

Best regards, Walter

Re: SunTracker - with moving ghost

Posted: Fri Aug 17, 2012 6:31 pm
by rpbras
Where can I find the version with the fix for the url-error?

Re: SunTracker - with moving ghost

Posted: Fri Aug 17, 2012 8:46 pm
by krambriw
Check the first post in this thread

Re: SunTracker - with moving ghost

Posted: Mon Aug 20, 2012 12:45 am
by holle75
Hello Walter, everything up and running. Nice.

Nevertheless i have one more question. what would be the script code to send a "light off" event 2 or 3 times with a delay inbetween like you do with the bursts in a controller for example?

i tried to send an event, then eg.plugins.EventGhost.Wait(2.0), again the event ..... but that doesn┬┤t seem to work properly

f.e.

Code: Select all

eg.TriggerEvent('LICHT.licht ON')        
        eg.plugins.EventGhost.Wait(2.0)
        eg.TriggerEvent('LICHT.licht ON')        
        eg.plugins.EventGhost.Wait(2.0)
        eg.TriggerEvent('LICHT.licht ON')        
        eg.plugins.EventGhost.Wait(2.0)
        eg.TriggerEvent('LICHT.licht ON')
any help would be appreciated

best

H.

Re: SunTracker - with moving ghost

Posted: Mon Aug 20, 2012 6:26 am
by krambriw
If you want to do something several times with a delay (or sleep) in between from a python script (or from any other code) I personally prefer to use threads because they are not blocking the main program (most likely you like the other parts of EG to be executing in parallel).

To use time.sleep or eg.Wait in a script is not good because it blocks everything during the sleep or wait period.

The following python script will instead work very well and allow the rest of EG to work in parallel and the way you asked for:

Code: Select all


from threading import Thread, Event


def burstCommand(burstCommandThreadEvent):
    for i in range(5):
        eg.TriggerEvent('LICHT.licht ON') 
        burstCommandThreadEvent.wait(5.0)
    burstCommandThreadEvent.set()
    print "Burst thread finished"


burstCommandThreadEvent = Event()
burstCommandThread = Thread(
    target=burstCommand,
    args=(burstCommandThreadEvent,)
)
burstCommandThread.start()
print "Starting burst thread"


Best regards, Walter

PS I know that I still have some wait or sleep statements in some of my plugins but I change those to threads if possible when I see them during the maintenance

Re: SunTracker - with moving ghost

Posted: Mon Aug 20, 2012 2:38 pm
by holle75
very nice Walter, thank you.

Re: SunTracker - with moving ghost

Posted: Mon Aug 20, 2012 4:06 pm
by Pako
Hi Walter!
I think you should use eg.Scheduler.
As you can see here, it greatly simplifies the code.

Code: Select all

def burstCommand(counter):
    counter -= 1
    if counter > -1:
        eg.TriggerEvent('LICHT.licht ON')
        eg.scheduler.AddTask(5.0, burstCommand, counter)
    else:
        print "Burst thread finished"
eg.scheduler.AddTask(0.1, burstCommand, 5)
print "Starting burst thread"
And I even think that it also consumes less CPU power. But maybe I'm wrong.

Pako