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.

Enable macro at certain day

If you have a question or need help, this is the place to be.
Post Reply
Samme
Posts: 33
Joined: Tue Nov 22, 2011 9:07 am

Enable macro at certain day

Post by Samme »

Hi, I've been thinking and looking at python (and I didn't understand much of it) and other stuff, but I can't figure out how to achieve this. What I want to do is to have the macros as follows:

Monday
Tuesday
Wednesday
etc...

They should all be executed by the same trigger, but, as you probably already figured out, only on the corresponding day, also, if possible, to set certain macros, lets say, every other week also the macros saturday and sunday should be triggered.

Unfortunantly there's no, as far as I know, calendar plugin, I've looked at the Scheduler and ScheduleGhost plugins. but not yet figured out a good solution. Any help appreciated!

Thanks!
piert
Experienced User
Posts: 321
Joined: Tue Jun 14, 2011 2:53 pm

Re: Enable macro at certain day

Post by piert »

Samme wrote: I've looked at the Scheduler and ScheduleGhost plugins!
Schedulghost should be able to do the trick. Set several schedules to trigger events for each day when you want some macro to be disbabled or enabled.
Create macro's to which you add actions that either enable or disable the actual macro's that you want to have enabled or disabled.
Move the event that occurs as a result of the scheduleghost schedules towards the macros as needed.
kalia
Experienced User
Posts: 109
Joined: Wed Aug 12, 2009 1:10 am

Re: Enable macro at certain day

Post by kalia »

Try a python script. I use the following to trigger an event at startup on weekdays (where %w is 1 [Monday] to 5 [Friday]) and if hour is after 1 PM and before 6 PM.

Note that %W (uppercase) represents week number (you could use that to trigger event every odd or even week number). Check out http://docs.python.org/library/time.html for all the directive descriptions.

Code: Select all

from time import strftime

if 18 > int(strftime("%H")) >= 13 and 6 > int(strftime("%w")) > 0:
    eg.TriggerEvent("test", payload=None, prefix="test", source=eg)
kalia
Samme
Posts: 33
Joined: Tue Nov 22, 2011 9:07 am

Re: Enable macro at certain day

Post by Samme »

Hi guys and thanks for helping me out, I've been thinking and trying various things, but I've come to the conclusion that the easiest way would be to generate a trigger at startup.

For example today, generate a trigger something like "day.wednesday" or something like that, could you help me with that?

Thanks alot!
kalia
Experienced User
Posts: 109
Joined: Wed Aug 12, 2009 1:10 am

Re: Enable macro at certain day

Post by kalia »

I will start the script for you. You should be able to finish it off.

Code: Select all

from time import strftime

if int(strftime("%w")) == 0:
    eg.TriggerEvent("Sunday", payload=None, prefix="day", source=eg)
elif int(strftime("%w")) == 1:
    eg.TriggerEvent("Monday", payload=None, prefix="day", source=eg)
elif int(strftime("%w")) == 2:
    eg.TriggerEvent("Tuesday", payload=None, prefix="day", source=eg)
elif int(strftime("%w")) == 3:
    eg.TriggerEvent("Wednesday", payload=None, prefix="day", source=eg)
... and so on
Last edited by kalia on Thu Oct 18, 2012 12:17 am, edited 1 time in total.
Samme
Posts: 33
Joined: Tue Nov 22, 2011 9:07 am

Re: Enable macro at certain day

Post by Samme »

Thanks Kalia! I've completed the script, but I get errors,

"Error compiling script"
"SyntaxError: invalid syntax, line 5"
etc...

...and even if I don't have a "line 5" I still get that error. Weird! Any ideas?

Code: Select all

from time import strftime

if int(strftime("%w")) == 0:
    eg.TriggerEvent("Sunday", payload=None, prefix="day", source=eg)
elseif int(strftime("%w")) == 1:
    eg.TriggerEvent("Monday", payload=None, prefix="day", source=eg)
elseif int(strftime("%w")) == 2:
    eg.TriggerEvent("Tuesday", payload=None, prefix="day", source=eg)
elseif int(strftime("%w")) == 3:
    eg.TriggerEvent("Wednesday", payload=None, prefix="day", source=eg)
elseif int(strftime("%w")) == 4:
    eg.TriggerEvent("Thursday", payload=None, prefix="day", source=eg)
elseif int(strftime("%w")) == 5:
    eg.TriggerEvent("Friday", payload=None, prefix="day", source=eg)
elseif int(strftime("%w")) == 6:
    eg.TriggerEvent("Saturday", payload=None, prefix="day", source=eg)
    
User avatar
Livin
Experienced User
Posts: 792
Joined: Wed Oct 08, 2008 4:56 am

Re: Enable macro at certain day

Post by Livin »

Now that I think about it, it is strange there is not a simple plugin for Day / Time trigger.

Maybe someone can convince Pako or Walter to create a streamlined plugin that only monitors/triggers based on Days/Times. The existing Scheduler & SchedGhost are more complicated than I ever needed, and a bit confusing to the average user. Having a simple plugin that logged day and time wold allow users to set a trigger.
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
kalia
Experienced User
Posts: 109
Joined: Wed Aug 12, 2009 1:10 am

Re: Enable macro at certain day

Post by kalia »

Sorry, it should be elif not elseif. I am new to Python.

Code: Select all

from time import strftime

if int(strftime("%w")) == 0:
    eg.TriggerEvent("Sunday", payload=None, prefix="day", source=eg)
elif int(strftime("%w")) == 1:
    eg.TriggerEvent("Monday", payload=None, prefix="day", source=eg)
elif int(strftime("%w")) == 2:
    eg.TriggerEvent("Tuesday", payload=None, prefix="day", source=eg)
elif int(strftime("%w")) == 3:
    eg.TriggerEvent("Wednesday", payload=None, prefix="day", source=eg)
elif int(strftime("%w")) == 4:
    eg.TriggerEvent("Thursday", payload=None, prefix="day", source=eg)
elif int(strftime("%w")) == 5:
    eg.TriggerEvent("Friday", payload=None, prefix="day", source=eg)
elif int(strftime("%w")) == 6:
    eg.TriggerEvent("Saturday", payload=None, prefix="day", source=eg)
Post Reply