scripting time range

Posted on
Mon Dec 12, 2016 11:43 pm
hensed offline
Posts: 59
Joined: Feb 01, 2012
Location: Oakland, CA

scripting time range

Hi All,

I'd like to set the brightness of a light, depending on the time of day; like from 10p-5am I'd like the brightness value to be n. How would I go about scripting the time range argument?

Posted on
Tue Dec 13, 2016 12:40 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: scripting time range

Can you describe a bit more what you're trying to do? Run through a scenario so we can fully understand the request.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Dec 13, 2016 12:45 pm
hensed offline
Posts: 59
Joined: Feb 01, 2012
Location: Oakland, CA

Re: scripting time range

Thanks Jay!! Sure!

I have a trigger that controls a light. When a motion sensor sends on, I would like that light to come on at 70% during the day, and 20% during "bedtime" hours - between 10p-5am.

I wanted to write a python script to that handles this (I can be swayed to better options as well), because I didn't see a way to do this with one trigger.

Posted on
Tue Dec 13, 2016 1:19 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: scripting time range

Ah, that's much better.

There are a lot of ways to do this:

  1. create 2 triggers and use a condition to limit which one actually fires
  2. Write a script and execute that as the trigger action

I personally would do #1 because, despite there being 2 triggers, I think it's more maintainable since you can adjust the times in the UI. The script will require the use of Python's datetime module to get the current time then test to see if it's between your two targets. I'll leave the details for you to investigate... ;)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Dec 13, 2016 3:45 pm
hensed offline
Posts: 59
Joined: Feb 01, 2012
Location: Oakland, CA

Re: scripting time range

Hi Jay!

Thanks you opened up my brain. I created a variable "bedtime" (maintained by a schedule) that I can use in other places as well. Wrote a trigger action script that checks the variable to determine the brightness level. :)

Posted on
Tue Dec 13, 2016 5:49 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: scripting time range

There are almost always multiple ways to do something in Indigo, none of which are particularly wrong/bad. It's just a personal preference. I almost proposed the schedule/variable approach, but it seemed a little overkill. But since you use it for other things it's a perfect solution.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Dec 13, 2016 6:48 pm
srkinard offline
Posts: 320
Joined: Apr 10, 2016
Location: Austin, Texas

Re: scripting time range

I used a variable called MasterDimLevel and it is changed via schedule. Most of my triggers will turn on a light using this value.
At 10pm it goes to 20%, at midnight it goes to 10%, at 6am it goes back to 20%, at 8am it goes to 40%, Noon goes to 80%, 6pm back to 40% and so on.

Still tweaking the levels to see what works best, but mainly I don't blast my eyes in the middle of the night when I walk into the bathroom.

Ross

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 8 guests