Schedules checking alarmClock

Posted on
Wed Apr 01, 2015 1:21 pm
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Schedules checking alarmClock

Hi all,

I have a variable "alarmClock" which I set (almost) every day to set, of course, the alarm clock for the following day
Idea is to have a schedule running every minute that check if "alarmClock = currentTime"

I thought this was possible using the conditional editor but I was wrong, need to move to the script editor...but the question is: is it AppleScript or Python? In Python should be no problem, something like:

Code: Select all
alarmClock = indigo.variables[123]
if alarmClock.value = indigo.getTime()
    indigo.device.turnOn("kitchen_light")


But it seems not working

Any help/hint?

Posted on
Wed Apr 01, 2015 1:38 pm
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Re: Schedules checking alarmClock

I found a workaround using a schedule running every minute which as action contains an embedded Python script checking the variables, but it seems not working

Code: Select all
import datetime

alarmClock = indigo.variables[469044268].value
currentTime = indigo.server.getTime()

indigo.server.log(alarmClock)
indigo.server.log(currentTime)

if alarmClock == currentTime:
   indigo.device.turnOn["KitchenLamp"]


Thanks
Marco

Posted on
Wed Apr 01, 2015 2:47 pm
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Re: Schedules checking alarmClock

I modified again my script and is working

Code: Select all
from datetime import datetime

alarmClock = indigo.variables[469044268].value

indigo.server.log("Alarm Clock is set at: " + alarmClock)
indigo.server.log("Current time is: " + datetime.now().strftime("%H:%M"))


if alarmClock == datetime.now().strftime("%H:%M"):
   indigo.device.turnOn("KitchenLamp")

Posted on
Thu May 07, 2015 12:42 am
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Re: Schedules checking alarmClock

I would like use the same logic to trigger an action (in this case, a "speak" action) implementing something like this:

Code: Select all
if currentTime is between alarmClock and alarmClock+30min, trigger the action


Is it possible in Python?

Thanks

Posted on
Sat May 09, 2015 9:16 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Schedules checking alarmClock

That pseudo script can't trigger - because it's a range. What's causing it to fire? If it's a Trigger or Schedule, then you can just use a time between condition without any scripting.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat May 09, 2015 10:03 am
SpencerJRoberts offline
User avatar
Posts: 256
Joined: Dec 09, 2012
Location: Mountain View, CA

Re: Schedules checking alarmClock

You can also tie it to a real Indigo Schedule and have the code modify the actual execution time of the schedule. That way you don't need to check every minute. I do this for a few different things. Unfortunately it is only possible via applescript as far as I know.

Code: Select all
tell application "IndigoServer"

        set myAlarmVar to value of variable "YOUR INDIGO VARIABLE HERE"

        set theSchedule to time date action named "YOUR INDIGO SCHEDULE NAME"
        set date trigger type of theSchedule to everyDay
        set absolute trigger time of theSchedule to date myAlarmVar

end tell


Replace the all-caps text with your info and that should do it, you just need to make sure that your time variable is formatted as "5:00 AM" or "5:15 PM". You may want to add another variable which is actually whether the alarm is enabled or not and make that a condition for the schedule, for the days you don't want it to wake you up.

Posted on
Wed May 20, 2015 12:33 am
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Re: Schedules checking alarmClock

Thanks for the suggestions.
I will modify the logic behind...

Thanks

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests

cron