Hi Rik,
In general, I think that such presence monitoring is not easy to implement. Especially not with 2 motion sensors. The source of error will be relatively high, e.g. if 2 people go up directly one after the other (is detected as 1 person), and later only 1 person goes down again.
To make these procedures more secure, the other rooms would also have to be monitored for movement. In my opinion, it would be even better if real presence sensors were used, however, there is currently no support for presence sensors, with the exception of the Homematic IP HmIP-SPI sensor (sorry, only in German language). However, this requires an additional gateway. I cannot say anything about the quality.
However, maybe the new Aqara FP2 presence sensor will be supported soon:
Regardless of the above problems, a possible way could be as follows:
Stair up
When…
– Motion sensor B (upstairs!) is activated
And…
– Motion-Alarm of MS A (downstairs!) is (still) on
Then…
– Logic card - Calculate “Variable” as {{Variable +1}}
Stair down
When…
– Motion sensor A (downstairs!) is activated
And…
– Motion-Alarm of MS B (upstairs!) is (still) on
Then…
– Logic card - Calculate “Variable” as {{Variable -1}}
So I would do the order the other way around.
However, if this works depends, among other things, on the used motion sensors and their settings (if possible, keyword “Blind time” and “Cancellation delay”).