Simple counter for alarm motion

Platform information:
    Hardware: Intel Core i5 Mobile / 12Gb Ram / SSD
    OS: Debian Buster
    Java Runtime Environment:build 11.0.6+10-post-Debian-1deb10u1
    openHAB version: 2.5.3

Hi,
I have an Aeotec ZWA005 Motion, light, and temperature sensor device.
It works very well, I would like a new feature with motion alarm but I don’t know how it is working with openhab.
When I configure the device, it says “Alarm motion : OK” as shown below

I already use temperature and luminance sensor to draw graphic into Grafana.
What I would like is quite simple (in my head, but not with my knowledge) : I would like to count every times the motion sensor is triggered. For this I tought two solutions :

  • Count +1 each time the motion sensor is activated, I would store the count in grafana dashbord
  • A database table especially configured for it ? Then I would just have to print the value in Grafana ?

I’m quite lost, if anyone has an idea.

Regards,

Doing the first point is quite simple. Create a number item, not linked to a channel, and postUpdate it on each change of your Alarm to by +1 to the actual state.

@unam just an example of what @opus mentioned:

var timerCount = 0
rule "timer"
when 
	Item Esp_Easy_Motion changed from 0 to 1
then
	if(Esp_Easy_Motion.state != NULL) {
		timerCount +=1
		timer.postUpdate(timerCount)
	}
end

rule "timer count"
when
	Item timer changed 
then
	if(timerCount >= 3 && Couch_Light.state != ON){
		Couch_Light.sendCommand(ON)
		timerCount =0
		timer.postUpdate(timerCount)
	}	
	else if(timerCount >= 3 && Couch_Light.state != OFF){
		Couch_Light.sendCommand(OFF)
		timerCount =0
		timer.postUpdate(timerCount)
	}
end

Just edit the rule to work as you need.