How to count number of events from sensor

Does anyone have any examples of how to count and store the number of counts for a sensor. Say a contact sensor, motion sensor or water sensor.

I'd like to set up a water sensor on my sump pump and count the number of cycles every day and store that if possible. I'd like to use hubigraph with this if possible, but I'm unsure of how to count each time for a sensor trigger.

I thought there was a worked-out example of this in HubitatPublic/example-apps at master · hubitat/HubitatPublic · GitHub but on closer review don't see a "Counter" app there.

The simplest solution likely involves writing a Rule Machine rule (or two) along with a Hub Variable of type Number. RM can do simple variable arithmetic (e.g. "add 1"), triggered by your monitored sensor values throughout the day, and if you reset said variable to 0 at midnight, it becomes a daily counter.

Up to you to script these rules, as well as account for whatever reporting (Notification or Graphing) you want done in conjunction. For that purpose, may I recommend WebCoRE's built-in Graphing facility, which includes a LTS (long-term storage) Fuel Stream to record variable values for you over time.

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