SunTracker - with moving ghost

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

Re: SunTracker - with moving ghost

Postby Lunatixz » Fri Jun 01, 2012 4:54 pm

I would like it to turn on at 2300, 0r 2359 and off at 0600...
but the plugin doesn't allow those timelines..
Lunatixz
 
Posts: 15
Joined: Wed Jul 07, 2010 7:16 pm

Re: SunTracker - with moving ghost

Postby krambriw » Fri Jun 01, 2012 5:37 pm

For fixed time settings you should use the scheduler plugin. It is also there for download somewhere in the plugin section

Best regards, Walter

Edit: you find it here:

http://www.eventghost.net/forum/viewtopic.php?f=9&t=818&hilit=scheduler
krambriw
Plugin Developer
 
Posts: 1144
Joined: Sat Jun 30, 2007 2:51 pm

Re: SunTracker - with moving ghost

Postby holle75 » Sun Jul 15, 2012 10:36 am

Hello Walter, i would like to use your Sun Tracker besides switching my lights at sunset/sunrise also in dependance to the weather conditions. Meaning, if the weather is cloudy, rainy, etc, bad by my definition at f.e. 14:00 i would like to switch on some lights. Would you mind to give me a little help for this Python Script? I can´t find the variable that holds the status of the weather.

what i like to have is something like ;

if variable.weather is "cloudy","rainy", "etc":
eg.triggerEvent switchOnLight
else
do nothing

thank you for any help

h.

EDIT: another question: when using moving ghost (in a separate "controler") Light ON and Light OFF is happending the whole day and not in between sunset/sunrise. I have no times defined in the Night OFF/Morning ON/Evening OFF settings .... but even if, moving ghost switches ON/OFF during the day.
holle75
 
Posts: 33
Joined: Thu Apr 19, 2012 5:47 pm

Re: SunTracker - with moving ghost

Postby krambriw » Mon Jul 16, 2012 2:42 pm

Hello,

Light ON and Light OFF is happending the whole day and not in between sunset/sunrise


You are right, this is a bug...I need to investigate this a bit.

Regarding your script, there are several ways this can be done. The simplest is first to activate the function "Create weather condition events" in the plugin so that it sends the current weather event every minute. The events would typically look like this:

16:05:27 Main.Weather Condition: 'Clear'

Then you catch these events with a python script in one or several macros. The weather data is in the payload and you have to match it correctly.
Image2.jpg
Image2.jpg (3.54 KiB) Viewed 642 times

Below is a simple script example (you can of course delete or move the weather conditions according to your personal need) you can start to experiment with.

Best regards, Walter

Code: Select all
if eg.event.suffix == 'Weather Condition:':
    theWeather = eg.event.payload
   
    if theWeather in (
                "Cloudy",
                "Fog",
                "Haze",
                "Light rain",
                "Overcast",
                "Mostly Cloudy",
                "Fair",
                "Heavy Rain",
                "Rain",
                "Rain Showers",
                "Rain Shower",
                "Ice/Snow",
                "Freezing Rain",
                "Freezing Drizzle",
                "Light Drizzle",
                "Drizzle",
                "Flurries",
                "Rain and Snow",
                "Showers",
                "Snow",
                "Light snow",
                "Snow Showers",
                "Isolated Thunderstorms",
                "Thunderstorm",
                "Chance of Showers",
                "Chance of Snow",
                "Chance of Storm",
                "Scattered Showers",
                "Mist",
                "Dust",
                "Icy",
                "Smoke",
                "Sleet"
    ):
        eg.TriggerEvent('switchOnLight')
   
    if theWeather in (
                "Partly Cloudy",
                "Clear",
                "Sunny",
                "Mostly Sunny",
                "Partly Sunny"
    ):
        eg.TriggerEvent('switchOffLight')
krambriw
Plugin Developer
 
Posts: 1144
Joined: Sat Jun 30, 2007 2:51 pm

Re: SunTracker - with moving ghost

Postby holle75 » Mon Jul 16, 2012 9:15 pm

Thank you Walter, your script works very nice. Right now i try to combine it with IsSunDown "true or false".

until now i fail ;) ... i am getting errors when i try something like
Code: Select all
if eg.plugins.IsSunDown == "false":
    print "yes" (lights switch on/off depending on the weather)

can you tell me how to combine your script with IsSunDown?

EDIT: or another thought: how to combine the script that it is working in the time when the sunTracker-controller with all compensations (weather, etc.) in the night is NOT switched on (in between nn OFF and nn ON)?

It would be great if you could find the moving Ghost bug.

thank you for your help

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

Re: SunTracker - with moving ghost

Postby krambriw » Tue Jul 17, 2012 4:55 am

This script uses the sun state with weather compensation:
Code: Select all
if eg.event.suffix == 'Weather Condition:':
    theWeather = eg.event.payload
    bSunIsDown = eg.plugins.Suntracker.IsSunDown(0, 30)
   
    if bSunIsDown and theWeather in (
                "Cloudy",
                "Fog",
                "Haze",
                "Light rain",   #For Google weather
                "Overcast",
                "Mostly Cloudy",
                "Fair",
                "Heavy Rain",
                "Rain",
                "Rain Showers",
                "Rain Shower",
                "Ice/Snow",
                "Freezing Rain",
                "Freezing Drizzle",
                "Light Drizzle",
                "Drizzle",
                "Flurries",
                "Rain and Snow",
                "Showers",
                "Snow",
                "Light snow",
                "Snow Showers",
                "Isolated Thunderstorms",
                "Thunderstorm",
                "Chance of Showers",
                "Chance of Snow",
                "Chance of Storm",
                "Scattered Showers",
                "Mist",
                "Dust",
                "Icy",
                "Smoke",
                "Sleet"
    ):
        eg.TriggerEvent('switchOnLight')
   
    if not bSunIsDown:
        eg.TriggerEvent('switchOffLight')
   


I believe you can actually use this simpler script. It uses the built in plugin function for getting the current sun status with compensation settings for weather and offset:
Code: Select all
if eg.event.suffix == 'Weather Condition:':
    theWeather = eg.event.payload
    bSunIsDown = eg.plugins.Suntracker.IsSunDown(0, 30)
   
    if bSunIsDown:
        eg.TriggerEvent('switchOnLight')
   
    if not bSunIsDown:
        eg.TriggerEvent('switchOffLight') 


The parameters (0,30) are ('fixed offset compensation', 'weather offset compensation') and they are working in parallel.

I am not really sure how you like the light control to function. If you want the lights to stay on during the time sun is down, you could actually configure this in the plugin action itself without any need for additional scripts.

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

Re: SunTracker - with moving ghost

Postby holle75 » Tue Jul 17, 2012 9:10 am

Hello Walter, thank you again!

1) My goal is to switch my lights on and off according to suntrackers sunset/sunrise (plus OFF by my definition at f.e. 01:15) (at night) if me or my wife is at home.
2) If me or she is NOT at home moving ghost should randomly switch OFF/ON only in between sunset/sunrise (at night) (thats how i found the bug).
3) if me or she is at home during the DAY i would like suntracker according to the WEATHER switch ON/OFF the lights and do nothing when we are out (we are living on the ground floor and sometimes its getting very dark if the weather is bad).

right now 1) is working good, 2) is complicated with the bug and 3) seems to be solved with your help now :) ... i will test today.

for 3) i´m using this script now (first line is to check if her or my iphone is logged into the wlan - thats another script defining a variable):

Code: Select all
if eg.globals.IphoneNicoleOUT == "False" or eg.globals.IphoneHolgerOUT == "False":   
    if eg.event.suffix == 'Weather Condition:':
        theWeather = eg.event.payload
        bSunIsDown = eg.plugins.Suntracker.IsSunDown(-60, 60)
   
        if not bSunIsDown and theWeather in (             
                "Fog",
                "Haze",
                "Light rain",
                "Overcast",               
                "Fair",
                "Heavy Rain",
                "Rain",
                "Rain Showers",
                "Rain Shower",
                "Ice/Snow",
                "Freezing Rain",
                "Freezing Drizzle",
                "Light Drizzle",
                "Drizzle",
                "Flurries",
                "Rain and Snow",
                "Showers",
                "Snow",
                "Light snow",
                "Snow Showers",
                "Isolated Thunderstorms",
                "Thunderstorm",
                "Chance of Showers",
                "Chance of Snow",
                "Chance of Storm",
                "Scattered Showers",
                "Mist",
                "Dust",
                "Icy",
                "Smoke",
                "Sleet"
        ):
            eg.TriggerEvent('LICHT ON')
   
        if not bSunIsDown and theWeather in (
                "Cloudy",
                "Mostly Cloudy",
                "Partly Cloudy",
                "Clear",
                "Sunny",
                "Mostly Sunny",
                "Partly Sunny"
        ):
            eg.TriggerEvent('LICHT OFF')
else:
    print "niemand da"


do you might know a workaround for the "moving ghost is also working day - bug"? i was trying with the command "moving ghost ON", "moving ghost OFF" from your plugin but do not understand how this works (there are no changes in moving ghosts behavior if i use ON or OFF)

best regards

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

Re: SunTracker - with moving ghost

Postby krambriw » Tue Jul 17, 2012 9:53 am

I think I have found the bug with the moving ghost, we should try this one and see if it solves number 2) for you
Best regards, Walter
__init__.py
(141.02 KiB) Downloaded 36 times


PS
Code: Select all
2) If me or she is NOT at home


should be ???

Code: Select all
2) If me AND she is NOT at home
krambriw
Plugin Developer
 
Posts: 1144
Joined: Sat Jun 30, 2007 2:51 pm

Re: SunTracker - with moving ghost

Postby holle75 » Tue Jul 17, 2012 4:36 pm

Hello Walter, i´m going to check moving ghost right now and this night.
Yes, it should be AND ;)

i´m getting back tomorrow

thank you

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

Re: SunTracker - with moving ghost

Postby krambriw » Tue Jul 17, 2012 6:16 pm

Hello, I have tested the moving ghost here as good as possible also by changing the local time in the computer and it seems to be working fine, at least here.

If you want to control the function ON/OFF you should select the "Enable Global Moving Ghost with external triggering" and then create a macro with a python script looking like this:
Code: Select all
if eg.globals.IphoneNicoleOUT == "True" and eg.globals.IphoneHolgerOUT == "True":   
    eg.plugins.Suntracker.SetMovingGhostON()
else:
    eg.plugins.Suntracker.SetMovingGhostOFF()


Then you can drop the events in the macro that shall trigger it and the script will change the Moving Ghost function depending on your presence at home or not. (try to figure out an event that doesn't confuse the system too much by coming all the time...)

What are you using to track if your iPhones are home or not?

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

Re: SunTracker - with moving ghost

Postby holle75 » Tue Jul 17, 2012 9:46 pm

Hello Walter, right now it seems to work perfect. Moving ghost is running since sunset and didn´t before. Thats what i needed. I will keep on testing whats happening tomorrow after sunrise (hopefully the ghost stops to move)
My main idea was to have the ghost moving during night automatically, so the logic would be to switch moving ghost on if suntracker sets sunset (automatically) ... and the moment the ghost wants to switch on/off the lights i´m checking if both iphones are out. With your script it´s kind of the other way around (switching ghost on if iphones are out ... could use sunset/sunrise as a trigger?). Might be better ....! EDIT: mmh, this way there might be a problem when the status of the iphones change during the night/late evening.

For setting the variables IphoneNicoleOUT and IphoneHolgerOUT i use the ping-plugin. Checking every 1 minute if they are connected with the router over wifi and after 15 minutes without response define them as gone. To make those devices respond in a 15minutes-frame i had to switch them to pull emails every 15 minutes. (I figured out that this is far less power consumptive than have push switched on). I also use it to play winamp with her playlist when she´s arriving at home. That helped to make her accepting me spending hours with programming ;)

i will get back tomorrow and let you know if the ghost is still moving or not ;)

thank you again for all your help

best regards

H.

P.S. is there any way to change the event for the weather from 1 minute to 10 minutes?
holle75
 
Posts: 33
Joined: Thu Apr 19, 2012 5:47 pm

Re: SunTracker - with moving ghost

Postby krambriw » Wed Jul 18, 2012 4:23 am

Hi, I have modified your script a bit so that it only updates the weather approx every 10 minutes. It still triggers every minute to check if one of you are IN.
(I figured out that this is far less power consumptive than have push switched on)

Very interesting finding, I need to change my settings in my Iphone, thanks

Best regards, Walter

Code: Select all
try:
    counter
except NameError:
    counter = 0

if eg.event.suffix == 'Weather Condition:'
    if counter == 0 or counter == 10:
        theWeather = eg.event.payload
    counter += 1
    if counter > 10:
        counter = 1

    if eg.globals.IphoneNicoleOUT == "False" or eg.globals.IphoneHolgerOUT == "False":   
        bSunIsDown = eg.plugins.Suntracker.IsSunDown(-60, 60)
   
        if not bSunIsDown and theWeather in (             
                "Fog",
                "Haze",
                "Light rain",
                "Overcast",               
                "Fair",
                "Heavy Rain",
                "Rain",
                "Rain Showers",
                "Rain Shower",
                "Ice/Snow",
                "Freezing Rain",
                "Freezing Drizzle",
                "Light Drizzle",
                "Drizzle",
                "Flurries",
                "Rain and Snow",
                "Showers",
                "Snow",
                "Light snow",
                "Snow Showers",
                "Isolated Thunderstorms",
                "Thunderstorm",
                "Chance of Showers",
                "Chance of Snow",
                "Chance of Storm",
                "Scattered Showers",
                "Mist",
                "Dust",
                "Icy",
                "Smoke",
                "Sleet"
        ):
            eg.TriggerEvent('LICHT ON')
   
        if not bSunIsDown and theWeather in (
                "Cloudy",
                "Mostly Cloudy",
                "Partly Cloudy",
                "Clear",
                "Sunny",
                "Mostly Sunny",
                "Partly Sunny"
        ):
            eg.TriggerEvent('LICHT OFF')
    else:
        print "niemand da"
krambriw
Plugin Developer
 
Posts: 1144
Joined: Sat Jun 30, 2007 2:51 pm

Re: SunTracker - with moving ghost

Postby holle75 » Wed Jul 18, 2012 11:14 am

Good morning Walter, power consumption may differ from iphone to iphone. Depending on Version, Firmware, amount of accounts you are pulling, etc .... but (for me and our two phones) it´s the only way to keep them in this 15-minutes-frame.... and in our case helped a lot with staying "iphone-alive" at least a day (by switching off push, not just switching on the 15-minutes-pull additionally) ..... and it´s always nice to not beeing connected with an Apple-Server! (as far as i know all push messages are going via apple). It´s also helpful to switch off iphones "ping" application (in system control).

moving ghost seems to have stopped at sunrise ... but i have to wait to confirm.

the new script gave me an error:

11:33:00 Error compiling script.
11:33:00 Traceback (most recent call last):
11:33:00 SyntaxError: invalid syntax (65, line 6)

i´m not enough experienced in Python to know why.
Anyway, my problem with pulling the weather every minute is the amount of messages you get in the log. Quite hard to find other messages after a while. I assume with the new script the amount of messages stay the same, just firing the event will only happen every 10 times?? ( i wasn´t clear in my previous post, sorry)

best

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

Re: SunTracker - with moving ghost

Postby krambriw » Wed Jul 18, 2012 12:27 pm

Embarrassing :oops:

Code: Select all
if eg.event.suffix == 'Weather Condition:'


should of course be and is more clearly written

Code: Select all
if( eg.event.suffix == 'Weather Condition:' ):


Maybe more errors will follow...

Regarding the frequency of the event populating your log, I have no setting available to avoid this. Instead there would be a possibility to fetch the weather condition from the script instead but it will require a small design change of the script with a timer that re-starts it let's say every 10 minutes. I can have a quick look at this...

Also, to avoid entries in the log is very difficult with scripts because they always leave a footprint, at least when they are executing. To make a really silent solution, you would need to make a plugin.

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

Re: SunTracker - with moving ghost

Postby krambriw » Wed Jul 18, 2012 2:44 pm

Here is another version of the script that is fetching the weather condition instead of getting it via an event. Once started, it will run again every 10 minutes until it is stopped. You can stop it by running a python command
Code: Select all
eg.globals.end = True
or by terminating EG.

One important notice: your global variables "eg.globals.IphoneNicoleOUT" and "eg.globals.IphoneHolgerOUT" must be existing BEFORE the script executes. If you put this script in the Autostart folder in the EG tree after the module that takes care of the initialization of the global variables above, it should be fine. Eventually you need also to add a wait statement in between.

If nothing else, we could add a try/except to the script as well but lets test this first.

Best regards, Walter

Code: Select all

def TheTask():
   
    theWeather = eg.plugins.Suntracker.GetWeatherCondition()
    #print theWeather

    if eg.globals.IphoneNicoleOUT == "False" or eg.globals.IphoneHolgerOUT == "False":   
        bSunIsDown = eg.plugins.Suntracker.IsSunDown(-60, 60)
   
        if not bSunIsDown and theWeather in (             
                "Fog",
                "Haze",
                "Light rain",
                "Overcast",               
                "Fair",
                "Heavy Rain",
                "Rain",
                "Rain Showers",
                "Rain Shower",
                "Ice/Snow",
                "Freezing Rain",
                "Freezing Drizzle",
                "Light Drizzle",
                "Drizzle",
                "Flurries",
                "Rain and Snow",
                "Showers",
                "Snow",
                "Light snow",
                "Snow Showers",
                "Isolated Thunderstorms",
                "Thunderstorm",
                "Chance of Showers",
                "Chance of Snow",
                "Chance of Storm",
                "Scattered Showers",
                "Mist",
                "Dust",
                "Icy",
                "Smoke",
                "Sleet"
        ):
            if not eg.globals.lights_ON:
                eg.TriggerEvent('LICHT ON')
                eg.globals.lights_ON = True
   
        if not bSunIsDown and theWeather in (
                "Cloudy",
                "Mostly Cloudy",
                "Partly Cloudy",
                "Clear",
                "Sunny",
                "Mostly Sunny",
                "Partly Sunny"
        ):
            if eg.globals.lights_ON:
                eg.TriggerEvent('LICHT OFF')
                eg.globals.lights_ON = False
    else:
        print "niemand da"

    if eg.globals.end == True:
        eg.globals.end = False
        print "Shutting down script..."
        print "Script is stopped"
        eg.StopMacro()
    else:
        remain = 600
        print "Next execution will start in "+str(remain)+" seconds"
        eg.scheduler.AddTask(remain, TheTask)

# Here we go...this is where the script starts
try:
    dummy #Only used to initialise some variables at startup
except NameError:
    dummy = 0
    eg.globals.end = False
    eg.globals.lights_ON = False

TheTask()

krambriw
Plugin Developer
 
Posts: 1144
Joined: Sat Jun 30, 2007 2:51 pm

PreviousNext

Return to Plugin Support

Who is online

Users browsing this forum: No registered users and 2 guests