TV mode

  • TRIGGER - time between 5:30 pm and 11:59 pm
  1. after 5:30 pm
  2. I turn the TV on
  3. lights dim
  4. turns lights off
  5. turns other lights on
  6. Works - perfectly
  7. I would like to kick it up a notch. For Example: If I turn the TV on at 3:00 pm and when it rolls around to 5:30 pm the rule fires. So no matter what time I turn the TV on when it gets to 5:30 pm it triggers the Actions to start.


#1 - This is NOT a trigger. It is a condition or expression. You have it stated correctly in your rule as a required expression. However, thinking of it as a trigger will get you headed down a wrong path. Syntax matters. A trigger is an instantanous event and cannot be a range of times unless you list multiple specific times (Which is not the same as "between" any set of times).
When you close a door, it is only an event (Trigger) at the exact instant it goes from open to closed. Then, as a condition, it IS closed until it is opened again.

It really sounds like you should just do a second rule. The main reason is that you have a restriction for between 5:30 and 11:59, and trying to add a trigger of 5:30 might act strangely.

Trigger: Time at 5:30
Actions:
IF Power level of TV > 60
Then
Do all your actions
End If

Your original rule should handle any instances of the TV being turned on

Another option would be to add a trigger of 5:31 to avoid any weirdness with having the time trigger and your required expression times. You will still want an "IF Power Level of TV>60" Then Do actions to prevent it from running when the TV is off.

2 Likes

All excellent points from Tray above -- I was going to suggest a similar second rule when I saw they were already typing a response, so :+1:

The one tweak I'd suggest to his is a helpful timesaver in 2-rule situations like this -- the Run Rule Actions command -- it simply runs the Actions portion of the called rule.

ETA - nuts, I intended to respond to Topic, not Tray specifically - apologies!

4 Likes

Some great suggestions! There are multiple ways to do this. Here’s another option:

Add a conditional trigger: Time = 5:31 PM if power level of TV() reports > 60

(There’s a conditional trigger option that is available when adding a trigger)

4 Likes

Is this right??



1 Like

There are 3 ways to use a conditional to control the if/when of a Trigger firing a rule (in no particular order):

  1. Required Expression (RE). This essentially serves as on on/off for the rule. When RE is True, any Trigger event fires the rule. When RE is False, it's as if the rule (and the Trigger) doesn't even exist.

  2. Conditional Trigger (CT). When the Trigger event occurs, its CT is immediately evaluated. If True, the rule fires. If False, it doesn't.

  3. An if-then Conditional in the Actions portion of the rule. Overall, this works very similarly to CT, but it certain cases, the slight difference in evaluation timing can be a factor.

Generally speaking, in many/most cases, these 3 options would all work equivalently; however, there are cases where the evaluation timing of the conditional becomes critical, and thusly edges one of these up to be the best choice.

Outside of those cases, it's just personal preference... When I build any rule, I work to limit as much as possible both how often its trigger gets evaluated, and then how often the trigger actually fires the rule. For any given rule build, that could mean I use any one (or combination) of those 3 options.

ETA -- out of the 3 options above, CT (#2) is the most recent addition... In a nutshell, Hubitat staff added it to help address some rare edge cases where the evaluation timing of an if/then conditional (#3 above) was otherwise problematic.

4 Likes

Thanks this was very helpful.

Can you share the trigger once you’ve clicked on « Done with this Condition »? From what I see in your screenshots, it seems to me that you have the trigger and condition reversed (I’ve done that on a few occasions…).

Yet another way to achieve this in one rule, is to have two conditional triggers:

  • When time is 5:30pm - only if power level of TV is > 60
  • Power level of TV reports > 60 - only if time is between 5:30pm and 11:59pm

One thing to be aware of is that you might get multiple power reports > 60 while the TV is on, depending on the power monitoring device. New such reports between 5:30pm and 11:59pm will trigger the rule again and the actions correspondingly will be run. It will still work, however, but any adjustments made manually to the controlled devices would get overridden by the rule. If this is a problem for you, there are ways to protect against that.

2 Likes

Looks like a great idea - I do not know how to write it yet.
Thanks

Sorta like the images below

How to Set Conditional Trigger

To learn about conditional triggers, click the "documentation" link in the top right of the forum page.

Then search for "conditional trigger" and click on the rule 5.1 that will be the first search result.

On the page that opens, on the right side of the page is a contents bar. Scroll down to "trigger events" and click that.

The paragraph that talks about conditional triggers will tell you that you need to select the toggle for "conditonal trigger" when creating your trigger.

Which, in the set up of the trigger looks like this

Sample Rule that should prevent re-trigger while already active and has the conditional triggers already mentioned. I do not have the same devices as you. So, you will need to add the same actions using your devices from your original set of actions.

1 Like