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.
User avatar
Livin
Experienced User
Posts: 792
Joined: Wed Oct 08, 2008 4:56 am

Re: SunTracker - with moving ghost

Post 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.
setup... XBMC, W7MC for DVR & Live OTA TV, JRMC for multi-zone audio, EG, MiCasaVerde Vera3, USB-UIRT IR receiver, Harmony remote, 5.2 home theater system
holle75
Posts: 33
Joined: Thu Apr 19, 2012 5:47 pm

Re: SunTracker - with moving ghost

Post 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.
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 »

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
User avatar
Livin
Experienced User
Posts: 792
Joined: Wed Oct 08, 2008 4:56 am

Re: SunTracker - with moving ghost

Post by Livin »

Yeah... LOVE the new version... working flawlessly for me! Walter... thank you again and again!
setup... XBMC, W7MC for DVR & Live OTA TV, JRMC for multi-zone audio, EG, MiCasaVerde Vera3, USB-UIRT IR receiver, Harmony remote, 5.2 home theater system
holle75
Posts: 33
Joined: Thu Apr 19, 2012 5:47 pm

Re: SunTracker - with moving ghost

Post 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.
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 »

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
piert
Experienced User
Posts: 321
Joined: Tue Jun 14, 2011 2:53 pm

Re: SunTracker - with moving ghost

Post 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).
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 »

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
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 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
rpbras
Posts: 5
Joined: Tue Jun 07, 2011 9:40 am

Re: SunTracker - with moving ghost

Post by rpbras »

Where can I find the version with the fix for the url-error?
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 »

Check the first post in this thread
holle75
Posts: 33
Joined: Thu Apr 19, 2012 5:47 pm

Re: SunTracker - with moving ghost

Post 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.
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 »

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
holle75
Posts: 33
Joined: Thu Apr 19, 2012 5:47 pm

Re: SunTracker - with moving ghost

Post by holle75 »

very nice Walter, thank you.
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: SunTracker - with moving ghost

Post 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
Post Reply