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.

Activate/desactivate action with time

If you have a question or need help, this is the place to be.
armada299
Posts: 3
Joined: Mon Mar 11, 2013 10:19 pm

Activate/desactivate action with time

Post by armada299 »

:?: Help! i need somebody :)

Hi,

I'm french user of eventghost, this software is beautifull. I have one question :

I have a macro for my homecinema room :

this is my macro

folder -
action -> light - on - (with switch king plugin)
action -> Play little sound
action -> open my flap (if the time is not in 8pm -> 3 am)

For the last action i can my this action with switchking but i want activate ou desactivate this action with check time :). My Pc is not open all day but maybe they are easy solution for this problem
miljbee
Experienced User
Posts: 146
Joined: Fri Mar 27, 2009 1:29 pm
Location: Orl├®ans, France

Re: Activate/desactivate action with time

Post by miljbee »

I don't know what means open my flap, but here is a general method to execute something only at certain times.

You will have to use a python script, and translate your action into python.

to do this, right click on your action Open My Flap, select copy as python
Had a new action : Python Script.

in the script editor, paste the previous copied action.

Disables the original action, and see if it's working.

Now, just add the needed code to filter based on time of the day :

Code: Select all

import time
now = time.localtime()
if now.tm_hour in [20,21,22,23,0,1,2]:
    put here the code needed to open your flap
Here is a sample action :

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1610">
    <Action>
        EventGhost.PythonScript(u"import time\ntime = time.localtime()\nif time.tm_hour in [20,21,22,23,0,1,2]:\n    eg.plugins.EventGhost.ShowOSD(u'Open My Flap', u'0;-64;0;0;0;700;0;0;0;0;3;2;1;34;Arial', (0, 255, 0), (0, 0, 0), 4, (0, 0), 0, 3.0, False)")
    </Action>
</EventGhost>
miljbee
TCP Events : A Better Network Event Sender/Receiver Plugin.
The Network Event Sender/Receiver in C#
Get events in EG from Google Calendar.
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Activate/desactivate action with time

Post by krambriw »

EDIT: Funny, miljbee, you just posted a proposal as well :D


You could do it like below using the python script below:

folder -
action -> light - on - (with switch king plugin)
action -> Play little sound
python script -> from below
action -> open my flap

Code: Select all

import time
timeStamp = str(
    time.strftime("%H", time.localtime())
)

if int(timeStamp) >= 20 or int(timeStamp) < 3:
    #Stop macro execution
    print 'Flaps do not open'
    eg.StopMacro()

    

armada299
Posts: 3
Joined: Mon Mar 11, 2013 10:19 pm

Re: Activate/desactivate action with time

Post by armada299 »

Thk's i test this this night. I have translate flap in google translate but maybe one image is better for explain my action :

flap :
http://www.grandsudhabitat.com/articles ... oulant.jpg
(maybe they are better word for this in english :) )

Thk's !!
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Activate/desactivate action with time

Post by krambriw »

In english this is a 'shutter'
armada299
Posts: 3
Joined: Mon Mar 11, 2013 10:19 pm

Re: Activate/desactivate action with time

Post by armada299 »

Yeeeeeeeeeeeeeeeeeeeeeeeeeees !! thk's!!!!!!! I use the last solution (more easy for me i'm a beginner in eventghost).
miljbee
Experienced User
Posts: 146
Joined: Fri Mar 27, 2009 1:29 pm
Location: Orl├®ans, France

Re: Activate/desactivate action with time

Post by miljbee »

I use the last solution (more easy for me i'm a beginner in eventghost).
Congratulations Krambriw !
miljbee
TCP Events : A Better Network Event Sender/Receiver Plugin.
The Network Event Sender/Receiver in C#
Get events in EG from Google Calendar.
Exile82
Posts: 13
Joined: Sat Jul 25, 2015 1:37 pm

Re: Activate/desactivate action with time

Post by Exile82 »

Sorry, I am gonna bump this old thread since I need som help with python coding (which I do not know). One certain event should pnly be triggered between 15 and 19. If that requirement is not fullfilled, this event should not be completed.
This is not working, it allows the event to be triggered and executed, no dependency on time of the day:
import time
timeStamp = str(
time.strftime("%H", time.localtime())
)

if int(timeStamp) >= 15 or int(timeStamp) < 19:
#Stop macro execution
print 'Kontroll av tid gjordes, OK! [kl 15 <-> 19]'
eg.StopMacro()

eg.plugins.TellStickDuo.TurnOn(u'Bottenv\xe5ning, Tv\xe4ttstuga, Taklampa')
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Activate/desactivate action with time

Post by krambriw »

Here you go,

The monitored time must be within the interval 15 <-> 19. This means allowed time must be >= 15 AND < 19

Code: Select all

import time
timeStamp = str(
    time.strftime("%H", time.localtime())
)

if int(timeStamp) >= 15 and int(timeStamp) < 19:
    #Stop macro execution
    print 'Kontroll av tid gjordes, OK! [kl 15 <-> 19]'
    eg.StopMacro()

eg.plugins.TellStickDuo.TurnOn(u'Bottenv\xe5ning, Tv\xe4ttstuga, Taklampa')

Exile82
Posts: 13
Joined: Sat Jul 25, 2015 1:37 pm

Re: Activate/desactivate action with time

Post by Exile82 »

Wtf? I wonder what I thought about when I set up the code. Of course you are right. I think I need to blame the "vacation brain" for this error.

Thanks krambriw, supportive as always!
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Activate/desactivate action with time

Post by krambriw »

Reading your posting a bit more careful, I might have misunderstood...the modified script I made will PREVENT the lights from being turned on between 15-17

If that is what you wanted, then it's fine

If on the other hand you wanted to ALLOW lights to be turned on only 15-17, the script shall look like this:

Code: Select all

import time
timeStamp = str(
    time.strftime("%H", time.localtime())
)

if int(timeStamp) < 15 or int(timeStamp) >= 19:
    #Stop macro execution
    print 'Kontroll av tid gjordes, OK! [kl <-15--19->]'
    eg.StopMacro()

eg.plugins.TellStickDuo.TurnOn(u'Bottenv\xe5ning, Tv\xe4ttstuga, Taklampa')

Exile82
Posts: 13
Joined: Sat Jul 25, 2015 1:37 pm

Re: Activate/desactivate action with time

Post by Exile82 »

Haha, great Krambriw! Actually I came back now because it didnt work as excpected. I will try this setup.
One question though, the python script should replace the "old" action, right?
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Activate/desactivate action with time

Post by krambriw »

One question though, the python script should replace the "old" action, right?
Yes, you one or the other depending on how you like things to work
Exile82
Posts: 13
Joined: Sat Jul 25, 2015 1:37 pm

Re: Activate/desactivate action with time

Post by Exile82 »

I really think I need to take a python crash course. It seems so simple but I cannot make this simple configuration to work. The lights turns on any time of the day when the magnet switch opens, despite that it is stated in the python code that should only execute the action between 15 and 19.
https://drive.google.com/file/d/0BwLlno ... sp=sharing

The python script that is present is a exact copy of the one you so kindly provided me with.

Any ideas would be much appreciated. I want to use the same concept on a bunch of things later on.

Thanks in advance!
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Activate/desactivate action with time

Post by krambriw »

OK, not really sure why but try this script instead. It should turn on the lamp only if time is between 15 and 19

Code: Select all

import time
timeStamp = str(
    time.strftime("%H", time.localtime())
)

if int(timeStamp) < 15 or int(timeStamp) >= 19:
    print 'Kontroll av tid gjordes, [kl <-15--19->]'
else:
    print 'Kontroll av tid gjordes, [kl 15<-->19]'
    eg.plugins.TellStickDuo.TurnOn(u'Bottenv\xe5ning, Tv\xe4ttstuga, Taklampa')

Post Reply