The Motion sensor Sonoff ZNZB-03P doesn't work with "AND" flow

Hi. When the sensors command is in the “AND” event, the flow doesn’t work after “WHEN” with other sensors or commands. But it works like it’s on a group “WHEN”.

Is this a bug in Homey or with the Sonoff app?

It’s just the mystery of witchcraft, …

if you get the right answer based o the information you provided.

Probably you tell us a bit more, like which Homey you have, how your flow looks like, what you are expecting and what you observed.

2 Likes

Homey Early 2023.

I discovered this when I was creating advanced flows. But even the simple flows don’t work as they should when this sensor is in the “AND” event.

Like example, in this flow it works when The motion alarm is on and I turn off and then turn on the socket (like it’s on a group “When” instead “And”). I see this only with this sensor.

What are you trying the achieve?

The flow you shared sends a notification message when you turn on the socket, but only if the motion alarm is on at that point in time.

When I first turn on the socket and then the motion alarm is on, nothing happens. (with other motion sensors everything ok). But when I turn off and on socket during the motion alarm, the flow works.

That is how it is supposed to work: only when both the WHEN condition (turning on the socket) and the AND condition (motion alarm is on) are true at the same time, then the message will be sent.

Can it be that the motion alarm is not yet on at the exact same moment as when you switch on the socket?

Not sure what you are tying to achieve.

Ok, how to achieve that if the socket is already on and then the motion alarm is on the message will be sent?

You need to swap the first two cards. So WHEN the motion alarm is triggered, AND the switch is on, THEN send a notification.

1 Like

Hi Vitalii,
That is a common misunderstanding, how flows work.
When is a trigger. That means homey does only start, as soon as the trigger is invoked. But then it does not wait for And cards, but looks immediately, if all And conditions are true. If they are not true at the same time, the flow stops or follows the Else path.
In your case the solution of @SunBeech should be sufficient. For more complex cases there are many examples here. If you don’t find them, you can ask again.

1 Like

Ok, thanks. And how to make an advanced flow with a Motion sensor and Door sensor that trigger almost simultaneously, if I don’t know what will start first? But the Door sensor should be triggered no more than 10 sec ago.

You can include multiple triggers in an Advanced flow, as long as you don’t join them with an ALL card. So both a WHEN motion alarm turns on and WHEN contact sensor alarm turns on. This way any of these triggers will start the flow.

Keep in mind that if both are triggered, then the flow is executed twice. You may want to include some logic in the flow that prevents you from receiving duplicate push notifications.

I know about multiple triggers, but if the first will be the Motion sensor in “When” value, and the Door sensor in “And”, how to add the rule that the Door sensor was triggered at this moment (no more than 10 sec ago)?

Some ideas:

  • You could use a Boolean (yes/no) variable that is set to Yes every time the contact sensor alarm is triggered and then a WAIT card set to 10 sec after which you change the variable to No. So, as long as the contact alarm went off no longer than 10 seconds ago the variable value would be Yes, otherwise No. as part of your flow you check the value of this variable;
  • You could use the Chronograph app to start a timer that counts down 10 seconds. In your flow you check whether the timer is active. If so, the contact alarm was triggered no longer than 10 seconds ago.

Ok, I’ll try. And do you know how to create the same flow, the Motion sensor is in “When” value, but the Door sensor is now off, but it was turned on and off nearly 10 sec ago?

You could create a flow that is triggered when the contact alarm is turned off. Then you add a wait card set to 10 secs. Then you set a yes/no variable (let’s say TurnedOff10To30SecsAgo) to Yes. Then add another wait card for the duration you want this condition to be true, e.g. 20 sec. After which you set the variable to no. So this flow would set this variable to Yes between 10 and 30 secs after the contact alarm turned off. You can check this variable in the other flow as part of the AND section. You could also achieve this with the earlier mentioned Chronograph app and/or other ways. Many roads lead to Rome.