Just for information, maybe somebody could use it.
This is my solution for defining different actions based on the press duration off my aqara buttons.
All you need is the pimatic-datetime plugin and a DatetimeDevice that refreshes every 500ms.
Define neccessary variables:
$press-start
$press-duration
Rules for calculation:
when state of aqara-switch is "1001" then $press-start = $datetime.unixTimestamp
when state of aqara-switch is "1003" then $press-duration = $datetime.unixTimestamp - $press-start
Rules for actions:
when $press-duration changes and $press-duration > 1000 and $press-duration <= 2000 then start dancing
when $press-duration changes and $press-duration > 2000 and $press-duration <= 3000 then open secret door and set $playerLevel = $playerLevel + 1
when $press-duration changes and $press-duration > 9000 then do really dirty stuff
... to be continued ...