How to trigger based on different inactive time for different motion sensors

I likes to control the thermostate based on:

one sensor stays inactive for 15 min or longer
OR
another sensor stays inactive for 30 min or longer

How can I achieve that? The 'trigger event' in the rule machine, can only set the same inactive time for both sensors.

by the way, I am new to this community. I was trying to attached the screenshot of my rule setup, but the system says "Sorry, you can't embed media items in a post."

You should be able to configure two trigger events, one for each sensor, which I expect would allow you to set different values.

To post pictures, you need to join the owners group.

2 Likes

Thanks for the quick reply.

I shall correct my original question, I like to achieve 'AND' , not 'OR'

one sensor stays inactive for 15 min or longer
AND
another sensor stays inactive for 30 min or longer

I tried separating the two sensor settings into two trigger events. but the Trigger Event uses 'OR' instead of 'AND' to test when there are multiple trigger events.

Hmm... I'm not sure .. would need to think about it some more. Best I can think of would be two separate rules, one for each sensor, setting a variable or virtual switch once each one reaches the timeout points (15 / 30 mins). In a third rule, once both switches / variables are on, do what you want to do and turn them off.

Not ideal, so hopefully someone has a better idea.

Iā€™ve got a very outside of the box idea that might work, but am completely unsure if it is the best practice. My thought is thisā€¦utilize the Zone Motion Controller app to create two virtual motion sensors. Select Motion aggregation but only select one sensor. Have the activity timeout be your length of your stay for the respective sensor. Do this twice, once for each sensor, so that you have two virtual sensors that mirror your intended triggers.

Once that is done, you need to write two rules to have it work. Take advantage of the new conditional triggers or use required expressions based off the virtual sensors. For instance:

Rule 1
Required Expression: virtual sensor 1 inactive
Trigger: virtual sensor 2 inactive

Rule 2
Required Expression: virtual sensor 2 inactive
Trigger: virtual sensor 1 inactive

Thanks for the suggestion, although it seems quite complicated.

Can Hubitat rule machine be improved by allowing 'AND' for a group of triggering events?

I know it says in the Rule Machine guide that 'AND' is not really needed, but this case is an example of 'AND' instead of 'OR'.

In Smartthings, Trigger Events can be either 'AND' or 'OR'

Ken

That is not how triggers on Hubitat works. Hubitat is event driven, if you trigger on an AND two events would have to occur at the exact millisecond to make the rule run. The OR in the triggers is the correct thing for this platform.

Your AND belongs in the Actions section of Rule Machine. You probably want a conditional action, but there are likely other ways to accomplish what you want to.

  • IF xyz
  • AND abc...
  • THEN do something

There are other posts from the app's author bravenel, that explain the AND situation better if you want to research why this works this way.

Edit to say:

Your triggers likely would be a simple "motion inactive" for these sensors. The 15/30 minute inactive period would be in the Actions section in the conditionals.

2 Likes

At this stage it may be worth describing to circumstances you are trying to handle with the rule. I.e. is it people entering and then remaining in a room.

Create a trigger for the 30 minute sensor and in the actions make it conditional if the other sensor has been inactive for 15 minutes.

2 Likes

Both need to be true...

Both would be true at that point. If the 30 minute sensor triggered the rule and the rule checks if the 15 minute sensor is also inactive for 15 minutes then both would be true and run the action.

1 Like

Another way would be. Trigger on both with an OR. And then set a condition action with an AND saying if sensor 1 has been inactive for at least 15 minutes and sensor 2 has been inactive for at least 30 minutes then run the rule.

2 Likes

To expand on @neonturbo 's point, and likely other's thoughts, the HE platform, and in particular RM, is based on events, which can now include a single device remaining in a single state for a period of time, but not more than one device in a state for different periods of time.

Your circumstance and/or alternate options in the HE platform are the more likely paths to finding a solution I expect.

My original suggestion around couple of rules that set / trigger alternate rules or virtual switches are likely what you are considering....