Trigger Condition

Posted on
Sun Jun 30, 2013 1:07 pm
CraigM offline
Posts: 578
Joined: Oct 28, 2007

Trigger Condition

I was setting up a trigger and was surprised that the condition I needed was not there. [v5.1.8]

if Current Day

Is
Is Not

Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday


Is this in v6?

Posted on
Sun Jun 30, 2013 1:49 pm
nsheldon offline
Posts: 2469
Joined: Aug 09, 2010
Location: CA

Re: Trigger Condition

No, this condition isn't in v6 either. However, in both versions 5 and 6 (and 4 too) you can use the simple AppleScript to test if the current day is a weekday or not.
Code: Select all
if weekday of (current date) is in {Monday, Tuesday, Wednesday, Thursday, Friday} then
   return true
else
   return false
end if

I use this condition in a number of my triggers and schedules.

Posted on
Sun Jun 30, 2013 1:59 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Trigger Condition

This is the first request we've had for this I think. I'll add it to the request list for some future version.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Jun 30, 2013 2:59 pm
CraigM offline
Posts: 578
Joined: Oct 28, 2007

Re: Trigger Condition

nsheldon wrote:
No, this condition isn't in v6 either. However, in both versions 5 and 6 (and 4 too) you can use the simple AppleScript to test if the current day is a weekday or not.
Code: Select all
if weekday of (current date) is in {Monday, Tuesday, Wednesday, Thursday, Friday} then
   return true
else
   return false
end if

I use this condition in a number of my triggers and schedules.


Thanks :D , I'll keep that in mind for the future, BUT my trigger already has 6 rules. You can't use rules AND a script?

Posted on
Sun Jun 30, 2013 3:36 pm
nsheldon offline
Posts: 2469
Joined: Aug 09, 2010
Location: CA

Re: Trigger Condition

CraigM wrote:
Thanks :D , I'll keep that in mind for the future, BUT my trigger already has 6 rules. You can't use rules AND a script?

No, but you might be able to convert the rules to a script.

Alternatively, you could create a schedule that repeats every day at midnight that updates an Indigo variable with the weekday name. Then compare that variable value to weekday names in your condition rules.

Posted on
Mon Jul 01, 2013 12:10 am
nsheldon offline
Posts: 2469
Joined: Aug 09, 2010
Location: CA

Re: Trigger Condition

Just a follow-up with a screen shot to better show what I mean.
Testing for Weekend.png
Testing for Weekend.png (92.36 KiB) Viewed 5870 times

Posted on
Mon Jul 01, 2013 1:19 pm
CraigM offline
Posts: 578
Joined: Oct 28, 2007

Re: Trigger Condition

nsheldon wrote:
Alternatively, you could create a schedule that repeats every day at midnight that updates an Indigo variable with the weekday name. Then compare that variable value to weekday names in your condition rules.


That would certainly work, but my big-picture goal is as new versions come out with new features, to redo and simplify the mess of multiple pieces previously needed to perform a simple task.

The schedule method would require 7 schedules just to tell Indigo what it already knows. Seems odd that if Indigo knows it is Wednesday, that we can't set a condition based on Wednesday.

Variables and Scripts are a beautiful thing, but I lean towards using them only when absolutely necessary.

I have been burned many times by making a device edit and then having to hunt down any/all references to it in AppleScripts. And being dependent on variables becomes an issue if the variable doesn't get set because of a glitch or power failure.

I would love to see a power failure feature that:
- Power is restored
- Indigo is back online
- Indigo checks time of power failure
- Indigo checks time of power restore
- Indigo executes all events that were missed between failure & restore

As always, thanks Nathan

Cross my fingers for v7 :?

Posted on
Mon Jul 01, 2013 2:21 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Trigger Condition

So - you'd rather do without the functionality because it requires too many parts or scripts? :?

And being dependent on variables becomes an issue if the variable doesn't get set because of a glitch or power failure.


The exact same thing can be said being dependent on devices because of power failures. Not sure I'm buying that argument.

Home automation, by it's very nature, is complex. The ability to perform some task, even if it requires several moving parts, has to be weighed against not having the functionality. We choose to enable the broadest possible functionality and then refine/simplify over time, based on customer feedback (demand) and ROI. There are literally thousands of items to consider including in any give release of Indigo. Demand to simplify something that's already possible is really scrutinized closely because for every one of those we do we can't do some new functionality that's not currently possible.

I don't know if we'll add weekday comparisons in conditions in Indigo 7 - but I can tell you that given current demand if it requires us to drop other functionality, like support for a new device type, the latter will win.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Jul 01, 2013 3:21 pm
nsheldon offline
Posts: 2469
Joined: Aug 09, 2010
Location: CA

Re: Trigger Condition

CraigM wrote:
...
That would certainly work, but my big-picture goal is as new versions come out with new features, to redo and simplify the mess of multiple pieces previously needed to perform a simple task.

The schedule method would require 7 schedules just to tell Indigo what it already knows. Seems odd that if Indigo knows it is Wednesday, that we can't set a condition based on Wednesday.

Variables and Scripts are a beautiful thing, but I lean towards using them only when absolutely necessary.

I have been burned many times by making a device edit and then having to hunt down any/all references to it in AppleScripts.

Indeed. I've been slowly reworking some of the more complex mechanisms I developed in Indigo 4 and 5 that can now be done with far less complexity using Indigo 6 features.

Actually, the schedule method wouldn't require 7 schedules, just 1. All it would do is
Code: Select all
set value of variable "TodaysName" to (weekday of (current date)) as text
Of course, that still requires the variable with that name to exist and would throw errors if it didn't (but at least you'd know by the Indigo log which trigger caused the error).

CraigM wrote:
And being dependent on variables becomes an issue if the variable doesn't get set because of a glitch or power failure.

I would love to see a power failure feature that:
- Power is restored
- Indigo is back online
- Indigo checks time of power failure
- Indigo checks time of power restore
- Indigo executes all events that were missed between failure & restore

That might be nice, as long as only the events that were dependent on power being available were delayed. Determining which events should and shouldn't be executed would be tricky to figure out without the end user touching each of their existing triggers, schedules, and action groups to give them priorities.

Posted on
Mon Jul 01, 2013 5:25 pm
CraigM offline
Posts: 578
Joined: Oct 28, 2007

Re: Trigger Condition

nsheldon wrote:
CraigM wrote:
...
That would certainly work, but my big-picture goal is as new versions come out with new features, to redo and simplify the mess of multiple pieces previously needed to perform a simple task.

The schedule method would require 7 schedules just to tell Indigo what it already knows. Seems odd that if Indigo knows it is Wednesday, that we can't set a condition based on Wednesday.

Variables and Scripts are a beautiful thing, but I lean towards using them only when absolutely necessary.

I have been burned many times by making a device edit and then having to hunt down any/all references to it in AppleScripts.

Indeed. I've been slowly reworking some of the more complex mechanisms I developed in Indigo 4 and 5 that can now be done with far less complexity using Indigo 6 features.

Actually, the schedule method wouldn't require 7 schedules, just 1. All it would do is
Code: Select all
set value of variable "TodaysName" to (weekday of (current date)) as text
Of course, that still requires the variable with that name to exist and would throw errors if it didn't (but at least you'd know by the Indigo log which trigger caused the error).


As usual I can always count on you to understand the issue, elegantly formulate a solution, and present it in a friendly helpful tone. Thanks Nathan, it worked perfectly!

Posted on
Mon Jul 01, 2013 5:40 pm
nsheldon offline
Posts: 2469
Joined: Aug 09, 2010
Location: CA

Re: Trigger Condition

Glad I could help!

Posted on
Mon Jul 01, 2013 6:22 pm
CraigM offline
Posts: 578
Joined: Oct 28, 2007

Re: Trigger Condition

jay (support) wrote:
So - you'd rather do without the functionality because it requires too many parts or scripts? :?


Where in my post did I say I wanted less functionality if it required too many parts? There is a huge difference between a streamlined elegant solution and pile of scattered dependent parts, even if both net the same result.

The difference has EVERYTHING to do with editing/understanding what you did at a later date, NOT being too lazy to create a lot of parts.

If it takes 20 parts to do something that's fine, but good luck finding them a year later when you need to make a functionally change.

Like the other loyal users, I come here for assistance so that I can optimize the product you sell for MY NEEDS. The public lecture on ROI and what HA is, was just uncalled for. It didn't solve any posted issue, but instead made me feel that my comments/questions are not worthy of this forum.

-- By the way there is a 5.1.8 bug in the conditions editor which I don't know if it has been corrected in v6.

When you select a [start on/end on] date in a schedule it only allows you to select from a list of correct days.
example: Sept 1 - 30, with 31 grayed out

In the conditions editor ALL months have 31 days and it lets you select days that don't exist.
example: Sept 31 can be selected, and if you save and go back it changes to Oct 1

Posted on
Mon Jul 01, 2013 7:00 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Trigger Condition

Perhaps we can both take a lesson in posting tone and etiquette then. Posting constructive criticism and enhancement requests can be a tricky thing sometimes.

We'll look into the condition bug - it's likely still in Indigo 6 since we didn't do much (if any) work in the condition editor between versions.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Dec 01, 2018 2:00 am
davinci offline

Re: Trigger Condition

If anyone is looking for the code for Python, here it is:

Code: Select all
from datetime import date
import calendar
my_date = date.today()
day = calendar.day_name[my_date.weekday()]

indigo.variable.updateValue(VAR_ID, str(day))

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 15 guests

cron