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?
if weekday of (current date) is in {Monday, Tuesday, Wednesday, Thursday, Friday} then
return true
else
return false
end if
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.
CraigM wrote:Thanks , I'll keep that in mind for the future, BUT my trigger already has 6 rules. You can't use rules AND a script?
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.
And being dependent on variables becomes an issue if the variable doesn't get set because of a glitch or power failure.
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.
set value of variable "TodaysName" to (weekday of (current date)) as text
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
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 isOf 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).
- Code: Select all
set value of variable "TodaysName" to (weekday of (current date)) as text
jay (support) wrote:So - you'd rather do without the functionality because it requires too many parts or scripts?
from datetime import date
import calendar
my_date = date.today()
day = calendar.day_name[my_date.weekday()]
indigo.variable.updateValue(VAR_ID, str(day))
Users browsing this forum: No registered users and 3 guests