SunTracker - with moving ghost

Questions and comments specific to a particular plugin should go here.

Re: SunTracker - with moving ghost

Postby holle75 » Wed Jul 18, 2012 3:17 pm

Phhhh, Walter, you crazy son ..... ;)

i can´t follow at all anymore! Nevertheless i´m going to test!
I switched off "create weather condition events" in the plugin and put your script in the autostart (after the script predefining iphones in/out)

let´s see what is going to happen the next 16 hours

thanks a lot, i´m geeting back
holle75
 
Posts: 33
Joined: Thu Apr 19, 2012 5:47 pm

Re: SunTracker - with moving ghost

Postby krambriw » Wed Jul 18, 2012 5:55 pm

Don't worry my friend, we will slow down and take it step by step until you are up to full speed...

The script might look a bit strange but it is not so complicated.

1) In the first upper part we define a function, TheTask(). The content inside TheTask() function is very similar to the previous script you already had. New things I added are
- the new way to get the weather condition
- a memory flag for the state of your lamps so that the event is only triggered when needed and not for every cycle (if you see that you need an event at every cycle, we can easily remove it)
- a section that allows you to terminate the script "from outside" using the "eg.globals.end" variable
- a section that adds a task to EG's built in scheduler for restarting the script after the desired time, in this case 600 seconds

2) At the end you have the start section of the script, it is here the execution starts. In this section we need to initialize some global variables since they will hereafter be used during runtime. For this, I use a trick that Bitmonster (the original author of EventGhost) once teached me:

Code: Select all
try:
    dummy #Only used to initialise some variables at startup
except NameError:
    dummy = 0
    eg.globals.end = False
    eg.globals.lights_ON = False


First time the script runs, "dummy" is not existing and you get a NameError exception which leads to that dummy as well as the other variables gets created and initialized. Next time the script runs, dummy already exists and therefore no more initialization...

The last line is then calling our function, TheTask(). From this point it will be a self playing piano until you kill it

Best regards, Walter
krambriw
Plugin Developer
 
Posts: 1151
Joined: Sat Jun 30, 2007 2:51 pm

Re: SunTracker - with moving ghost

Postby holle75 » Thu Jul 19, 2012 10:50 am

....crazy son of a walruss ;) .... Walter, it works LIKE A CHARM!.... thank you very much.

And after your explanation i still wouldn´t be able to write it but now i do understand it.

still have to test cause weather is not changing enough at the moment but it seems fine.

I just have one very little, little unsatisfying thing going on in my log. It comes with moving ghost during the night and indicates the time, sunrise and sunset every minute. see picture.

eg.jpg


again thank you very very much for all your time and patience

best regards

H.

P.S. is there a way to check the suntracker with the defined ON/OFF times of the controller with a script? Hard to explain what i mean, but with the scripts we use we can only check if sun is up or down and not if the controller set f.e. On at 11:00 and OFF at 01:46.
holle75
 
Posts: 33
Joined: Thu Apr 19, 2012 5:47 pm

Re: SunTracker - with moving ghost

Postby krambriw » Thu Jul 19, 2012 12:17 pm

No problem,
Take this version (I had a print statement left in your version just to check that everything was working ok)

__init__.py
(141.02 KiB) Downloaded 21 times

I am happy to hear that it works for you, you have a cool solution now!

Regarding the script, I have made some further improvements but we can discuss that later when you have been running the current one for a while to see if you find something more that needs to be changed.

Best regards, Walter

PS
is there a way to check the suntracker with the defined ON/OFF times of the controller with a script?

No there no such possibilities. However, there is a log file you could read from where all ON/OFF actions are logged. In Python you can do almost anything like opening a file, reading the content and finding eventually what you are looking for.
krambriw
Plugin Developer
 
Posts: 1151
Joined: Sat Jun 30, 2007 2:51 pm

Re: SunTracker - with moving ghost

Postby holle75 » Fri Jul 20, 2012 8:03 pm

Hello Walter, i´m still checking my scripting skills ;)

i did pick up your idea to trigger the ghosts ON/OFF with my iphones.

it seems that using

Code: Select all
eg.plugins.Suntracker.SetMovingGhostON()
eg.plugins.Suntracker.SetMovingGhostOFF()


doesn´t switch my two controllers defined with moving ghost.

maybe i misconfigured those two controllers? do i have to define wich controller by name if there are some of them?

Enable Local moving ghost is switched OFF and enable moving ghost with external triggering is ON

even after switching OFF the Ghosts i get events in the log.

any ideas?

best

H.

edit: mmh, maybe just the last OFF event when before switching OFF there was an ON event on a ghost? not so easy to track ....
holle75
 
Posts: 33
Joined: Thu Apr 19, 2012 5:47 pm

Re: SunTracker - with moving ghost

Postby krambriw » Sat Jul 21, 2012 9:20 am

Hello,

I think the basic function works but it is difficult to verify. In addition I think the function can be improved as described a little further below.

To make it easier to verify the function, I suggest that you temporary change the time settings to much smaller values and then set the PC clock so that you are simulating a sun down state. I have made my settings like this:
Image2.jpg

I have two controllers running with the same settings and they are activating ON/OFF randomly with some difference in between as I expect. If you change the external trigger with "eg.plugins.Suntracker.SetMovingGhostON()" or "eg.plugins.Suntracker.SetMovingGhostOFF()" you will have to wait until the beginning of the next minute before it has an effect.

I defined two simple macros to toggle the function (just using a simple RF remote control, the disabling/enabling the macros when they are triggered, is not needed actually)
Image4.jpg

Also, a limitation with the current implementation, when the Global Moving Ghost (GMG) function ends, it leaves the lamps "as is" and there state will not be changed until the next standard ON/OFF event occurs (or if the GMG is started again). There is a little bug I found here as well; if you had synchronization checked, it will not start again after the GMG once have ended. There is room for improvements, including fixing the bug of course.

In the attached version below, I have made the changes accordingly:

- a running control with synchronization active will now correctly return to this when the GMG ends
- lamps will still be left "as is" when the GMG ends
- lamps will after this be correctly synchronized
    - when the synchronization takes place (if selected and checked in the settings)
    - at normal ON/OFF times
    - if/when the GMG is started again
- you still have to allow time to elapse to the next minute until you see an effect when starting/ending the GMG
- there is now a printed statement in the log when the GMG is starting and ending (this can easily be commented out when we have verified that everything is working as expected)
__init__.py
(141.94 KiB) Downloaded 19 times

Best regards, Walter

PS We do not have a problem with the Local Moving Ghost functions since there we are restarting the controller if you change the setting
krambriw
Plugin Developer
 
Posts: 1151
Joined: Sat Jun 30, 2007 2:51 pm

Re: SunTracker - with moving ghost

Postby holle75 » Sat Jul 21, 2012 10:50 am

Hello Walter, i´m going to check.

Did i understand you right that the "state" of the lamps will be left like they are when switching GMG OFF? Cause i think the oposite problem occures in my case. Lets say GMG is switched on, one of the controllers sends an ON event. Good. Then, in my case, when switching GMG OFF, after a while (i suspect according to a running timer) the same controller still is sending an OFF event. This is messing up the rest of my script logic ;) .... for me to switch off something means nothing should happen anymore ;)

mmh, i might have an idea why in my case GMG is behaving this way: when one of the iphones is entering the house i send the eg.plugins.Suntracker.SetMovingGhostOFF() command. When the other Iphone is also entering, i send the command again. (cause in both cases, when an iphone is entering i want to switch of GMG)

this means, even when GMG is switched OFF the same command will be send again. Maybe this triggers the (not expected) "late" event?

lamps will after this be correctly synchronized

- when the synchronization takes place (if selected and checked in the settings)
- at normal ON/OFF times
- if/when the GMG is started (stopped????) again


best

Holger
holle75
 
Posts: 33
Joined: Thu Apr 19, 2012 5:47 pm

Re: SunTracker - with moving ghost

Postby krambriw » Sat Jul 21, 2012 4:51 pm

Hello Holger,

Did i understand you right that the "state" of the lamps will be left like they are when switching GMG OFF?

Yes, this is how it works for me here

for me to switch off something means nothing should happen anymore

Agree with you

When the other Iphone is also entering, i send the command again

I need to verify if this causes a problem or not. Try with only one phone first. Eventually you will have to change the iPhone script a bit so that it delivers an event for the first phone that enters but not again if another one moves out and in a couple of times (Next trigger shall only happen if it has been totally empty in between).

Best regards, Walter
krambriw
Plugin Developer
 
Posts: 1151
Joined: Sat Jun 30, 2007 2:51 pm

Re: SunTracker - with moving ghost

Postby holle75 » Sat Jul 21, 2012 10:21 pm

Hi Walter, i just figured out that the OFF command is simply ignored for the FIRST event by GMG in my case.

If GMG is switched OFF, at sunset, my two "ghost-controllers" firing up the GHOST-ON-event (at slightly different times according to their settings)
After that, no events are happening anymore.

according to your explanation

it leaves the lamps "as is" and there state will not be changed until the next standard ON/OFF event occurs


if sunset is defined as a standard ON/OFF event, that makes sense, but is not "helpful" ;)

I think, if a ghost is switched off, logically nothing at all should happen until you switch it ON again.

EDIT: i have to verify but think now i understand GMG ;) .... and actually makes sense. If you switch GMG OFF, GMG is TRIGGERING an OFF EVENT. At sunset (where GMG is switched on by the plugin itself) GMG is TRIGGERING an ON event (even when manually switched OFF). If i switch OFF GMG twice, the Ghost confirms by triggering the event OFF, even if allready switched OFF. So, the logic is fine! ... but me and my little brain thought, when GMG is switched OFF, NO event at all is triggered. It´s just a different Logic.
holle75
 
Posts: 33
Joined: Thu Apr 19, 2012 5:47 pm

Re: SunTracker - with moving ghost

Postby krambriw » Sun Jul 22, 2012 7:48 am

Good Morning Holger,

I think you are not thinking wrong, this topic is a bit complex and there are many variants possible. I started also to think about other possibilities.

The current design is made in such a way that you can define and start an (unlimited?) number of controllers as you have seen. The MG and GMG are just sub-functions of the controller or, maybe better expressed, the controller can have different operational modes; normal, MG and GMG. If MG and GMG are turned off, the normal operation takes on.

But our discussion leads to new ideas; what about if I could in addition make it possible to define and start a controller type dedicated only for MG and GMG (I will keep the current type as is). There could be cases where this would be a better choice, like in your case.

If so, this MG/GMG controller would not go into "normal mode of operation" when MG/GMG ends because such a mode would not exist. Only question is, in case lamps are ON when MG/GMG ends, should the lamps stay ON or should they be turned OFF?

Best regards, Walter
krambriw
Plugin Developer
 
Posts: 1151
Joined: Sat Jun 30, 2007 2:51 pm

Re: SunTracker - with moving ghost

Postby holle75 » Sun Jul 22, 2012 12:50 pm

Hello Walter,

another controller for the "simple cases" would make sense in my opinion.

My original understanding was that GMG would not trigger any events after being switched OFF or the moment it is switched OFF. Whatever is happening after that command, should also not trigger an event.

Only question is, in case lamps are ON when MG/GMG ends, should the lamps stay ON or should they be turned OFF?


following my "simple logic", if GMG is switched OFF, "status" of the lamps would not change. No event should be triggered. EDIT: also if the sun sets or rise there shouldn´t be an event, cause GMG is still switched OFF.

the moment GMG is switched back ON, the first event, according to the defined "zones/times" (TIME ON/OFF, Inside sunset/sunrise or around the clock) would be ON, right? cause the GHOST was switched OFF before ???? very tricky, as you said ;)

EDIT4: Yes, cause a lot of manual/scripted ON/OFF f.e. the lights might had happen in between switching GMG OFF and now back ON again. So why should the Ghost change the status of the lights just by be switched ON or OFF? The first event should happen according to the settings and should be ON?! ... f.e. you leaving the house at 16:00 (you switch off all lights) and switch GMG ON. The first ON-event should happen at sunset and not the moment you switch GMG ON, also when coming home at 02:00 you want to keep the status (or switch all lights ON) and just switch GMG OFF for the rest of the night (without triggering the OFF event, cause you switched all the lights on the moment you entered home) ...

what are your thoughts?

best

H.

EDIT: maybe be able to use the TIME ON/OFF options to tweak the GHOST would be nice? EDIT2: Maybe an option to restrict the GHOST inside sunset/sunrise or all around the clock?
Last edited by holle75 on Sun Jul 22, 2012 3:04 pm, edited 1 time in total.
holle75
 
Posts: 33
Joined: Thu Apr 19, 2012 5:47 pm

Re: SunTracker - with moving ghost

Postby holle75 » Sun Jul 22, 2012 2:56 pm

i did edit the post above around 10 times ;) ... i hope you are not stuck reading an old version.

Interesting how complicated a movin ghost could be :D
holle75
 
Posts: 33
Joined: Thu Apr 19, 2012 5:47 pm

Re: SunTracker - with moving ghost

Postby krambriw » Sun Jul 22, 2012 5:37 pm

Hi again,

I have made a change so that it is now possible to run a controller exclusive as a moving ghost. Here it is only activating between sunset and sunrise and it will not turn off lights if they are on, they should be left as is.
__init__.py
(143.8 KiB) Downloaded 30 times

To activate, you have to check the box "Exclusive usage" in the Moving Ghost section. Some of the other settings are also not applicable when you are running it this way:
Image1.jpg


You need to upgrade from the previous version:
- disable the Suntracker plugin and the controllers in EG, save and exit EG
- replace the files with the attached file
- restart EG
- enable the Suntracker plugin
- open the configuration dialog for each of the controllers
- check the box "Exclusive usage" where you need it
- click OK, enable and start it
- save EG

I cannot guarantee that everything works perfect, I hope it works, but we need to test it

BestR Walter
krambriw
Plugin Developer
 
Posts: 1151
Joined: Sat Jun 30, 2007 2:51 pm

Re: SunTracker - with moving ghost

Postby holle75 » Sun Jul 22, 2012 8:43 pm

Hello Walter, thank you, i´m going to test the new file. From tomorrow on i´m off for holidays for 2-3 weeks so cannot get back with new information. Afterwards i will. Thank you for your help.

best regards

H.
holle75
 
Posts: 33
Joined: Thu Apr 19, 2012 5:47 pm

Re: SunTracker - with moving ghost

Postby Livin » Sun Jul 29, 2012 12:20 am

Walter,
I've not needed your awesome plugin until now... but either I'm missing something, or I have feature requests ;)

I don't need to "schedule" actions/macros BUT I do have the need for global variables which I can check (within a macro) to see if specific actions should be allowed to complete.

Specifically I need things the Twilight plugin calculates (dawn/dusk with twilight variations) plus the ability to have a time offset, for each individual Action.

Example:

Macro: WATCH MOVIE
-- Action: turn on tv
-- Action: turn on dvd player
-- Action: IF SunTracker Dawn/Dusk Status >= astronomical.dawn + 30 minutes THEN continue macro, ELSE stop macro
-- Action: turn on light to 30%

Is this something you could add?
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
User avatar
Livin
Experienced User
 
Posts: 749
Joined: Wed Oct 08, 2008 4:56 am

PreviousNext

Return to Plugin Support

Who is online

Users browsing this forum: Google Adsense [Bot] and 4 guests