Author Topic: Counting the total time sensor was triggered during defined period.  (Read 212 times)

Offline kwieto

  • Full Member
  • ***
  • Posts: 193
  • Karma: +8/-5
I want to make a scene which triggers a switch if sensor is triggered (that's the easy part).
the catch is that I want to turn the switch on only if sensor was triggered for (total) at least "n" time during i.e. last hour.
There is a thread with a solution how to handle it if sensor was triggered once and the time was long enough (i.e. 5 minutes), but is there a way to handle it in case where there was not one long event, but a couple of short ones (i.e. 5 events each 1 minute long)?

Frankly speaking I have only a vague idea how to approach this issue:
I can probably set a scene triggered by sensor which checks every second if it is still triggered and then calculate timing by comparing two values (start/stop), but how to sum up several events?


Offline RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9741
  • Karma: +737/-136
    • RTS Services Plugins
Re: Counting the total time sensor was triggered during defined period.
« Reply #1 on: September 04, 2017, 11:08:07 am »
Use PLEG

The multi-click operator
        DoorSensor @ 5 < 1:00:00


The above will only be true if DoorSensor goes true at least 5 times in the preceding hour.

Offline kwieto

  • Full Member
  • ***
  • Posts: 193
  • Karma: +8/-5
Re: Counting the total time sensor was triggered during defined period.
« Reply #2 on: September 04, 2017, 02:41:22 pm »
I will give it a try, thanks!

I assume in place of a DoorSensor I should define the sensor I use (Fibaro universal binary, if it does mater)?

[update]:
After second thought, it is not exactly the solution. each trigger even can have different length, i.e. 1min., 2min, 30sec., 15sec., and so on.
Counting number of events doesn't take this into consideration, 5 events 1min. each give the same result as 5 events 10sec. each, while in second case the total time is less than one event from the first case.
 
In the meantime I took another approach, which is maybe easier - to count total triggering time regardless of time period, i.e. turn off device each case the total time of triggering events reaches 5 minutes.


« Last Edit: September 05, 2017, 03:30:24 am by kwieto »