Help with RM4

Ok everyone you have been great in the past about helping. I'm still learning RM4 and have received excellent help in the past! How can I accomplish this in RM4? I want my hue TV back lights and hue go to turn on and off when the TV is turned on and off. I have it set to 30 minutes after sunset but honestly as long as it is getting a little dusky outside I'm fine with that and it honestly would work better I think. Anyway I have a Roku TV in my living room and the roku lite driver installed.

I see the TV is polled every 30 seconds but I'm just not sure what is the best way to accomplish this? Did I mention I'm still learning RM4? This is the rule I currently have and I know this only covers turning them on I'm not sure how the or got in there and was not sure how to set that to an and.

Any help would be much appreciated. Maybe one day I will learn enough to help others?

Amatuer here also. I like to write rules differently than this. I think it might work, depending upon your goal. The thing I see is it won't turn off the Hue the way you have it. The only other thing I might suggest is you don't want the lights on no matter what at sunset, right? You want TV on too.

The way I would do this is to...

TV on physical changed

IF TV is on
AND time is between Sunset and Midnight
Then ON Hue XYZ, ABC, DEF temperature whatever.

ELSE IF TV physical is off
THEN turn off Hue XYZ, ABC, DEF


I'm probably forgetting something, but this would be a starting point.

1 Like

So, I assume you want these lights to turn on if the TV is turned on but only if it's later than sunset? If so, the above rule looks good to me! (Good job, @neonturbo, for a self-described "amateur"!)

There may be some edge cases you'd need to think about: do you want the lights to always turn off if the TV is turned off, even if this rule didn't turn them on (say you turned them on manually before the TV for some reason)? If this rule turned them on, do you still want them to turn off even if it's outside your "on" conditions (after sunset, etc.)? The above should do both--it will turn them off any time the TV is turned off, regardless of time and regardless of whether this rule turned them on (or would have); you can add a bit more logic to handle these cases differently if so desired. Myself, I think I'd want the rule as-is so they're never left on, but your wishes may vary.

If you're interested in learning why: a trigger is more or less a momentary event, i.e., something that has no duration. Two triggers can therefore not happen at the same time because they are dimensionless events. That's why all triggers are ORed together for you: your "Actions to Run" section will run any time any of your trigger events fire, so Rule Machine translates this into English by adding an "OR" between triggers for you. (You can create triggers that combine multiple devices and trigger only if all [your options are "all" or "any"] are then in a certain state, but that's a single trigger with RM doing some work for you behind the scenes and not really relevant here since there's no way to do that with different device capabilities.)

If you want to check for two conditions being true at the same time--in your case the TV being on/off (or really, turned on or off--a good clue that you'd want this as a trigger) and it being after sunset (an event you want to check for but don't need to do anything when it actually happens--a good clue you only need it as a condition and not a trigger), you can use IFs in your rule actions to make that happen, as above.

I'd start with thinking about what your triggers need to be and then create everything else from there, but it's sometimes tricky to determine without thinking about your actions (and conditionals) too. This may not be the best advice since it is sometimes only clear in retrospect, but it's definitely at least something I like to at least try to think about. :slight_smile:

Hope this helps!

1 Like

Thank you that is what I keep forgetting about. The changed I always try to specify the state i want it in to fire action. Thanks I think this will help. I used webcore before and although I was no expert I was starting to understand the logic.

Still struggling with RM4 though. Just a matter of time I hope!

Thank you for the info this helps tremendously and I appreciate the effort on your part to help me understand.

@neonturbo See below for what I came up with based on your input. Unfortunately it's not working. I'm not sure why it shows on on both rules I did not add that and when selecting my device I simply selected my Roku TV and the power stated I wanted it to be in for the rule to run. I'm tagging @JasonJoel as I believe he uses the light driver and has a rule setup to do what I want it to do.

This rule will only turn on the lights if the TV is on at exactly sunset. If you notice @neonturbo's rule had between sunset and midnight. If you modify your rule and select a time between, it should work. It will turn on the lights in between those two times specificed, and it will turn them off outside those times (when the TV is turned on or off - the trigger).

1 Like

@mike Thanks I completely missed this part somehow. I will update it when I have time and see what happens.

This should work right? I'm not able to test it now of course.

No, you need to go into that page where you select sunset and there is a checkbox (at the top???) that asks if you want to use between two times.

You'll (probably) need to delete both the sunset line and the 4pm line and re-create that line of the IF statement.


1 Like

OK one more time I hope. Thanks for the help BTW.

You will want to add to the first line AND Living Room TV is ON (an easy modification, just click on it and it will allow you to add an extra condtion, first press AND).

As you currently have it, it will turn on the lights even if TV is off, which meas that the ELSE-IF would only be true betwen sunup and sundown.

1 Like

Like this apologies I'm still learning RM4.

1 Like

Should work.

I like to break up my IF statements instead of ANDing them, but either way works. I would have done:

if TV=on THEN
-----if time between x and y then
----------Light does something
-----end if
-----light does something else
end if

1 Like

Thanks for weighing in are there advantages to breaking them up?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.