Is there an easy way to set variable by counting selected devices that are in specific states?

I tried searching but did not find an answer.. If I am just bad at searching I apologize.

I am trying to get counts of specific state for devices in specific groups, it can be numbers like this:

  • How many contacts in my perimiter are opened?
  • How many lights in my interiors are on?

The list can go on.. It is mainly about a count of selected devices in specific states.

So far I figured out a way to achieve this is to setup rules like this:

Rule: counter_increase
Trigger: (ALL contact I care about) change to opened
Action: contact_opened_count add 1

Rule: counter_decrease
Trigger: (ALL contact I care about) change to closed
Action: contact_opened_count add -1

While this does work somewhat ok, I can kinda see there could be issue down the road - event that happened when device went offline won't get counted, when hub was reset the number could be off.. etc

I wonder is there a better way to achieve this?

Is there a way to "COUNT" device in specific condition, return an integer, and then I can set the outcome into a variable directly?

If there is not.. is there a way to add this feature?

Use my app.

3 Likes

OMG I posted the question not even 1 minute..

Are you wired into this forum?

Thanks will be checking out the app

3 Likes

I have the "Rule Machine" section set to alert me when there's a new post.

7 Likes

That's dedication...

Thanks again!

2 Likes

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