Homey Community Forum

How to debug flow(s)?

A complex flow (set of flows) is failing and I want to debug it. How can I do that?

This is the setup:

  1. When vibration alarm starts: set variable mailbox.open to Yes (after 10 seconds)
  2. When vibration alarm stops: set variable mailbox.open to No (immediately)
  3. When motion sensor alarm starts: set hall.movement to Yes (immediately)
  4. When motion sensor alarm stops: set hall.movement to No (after 1 minute)
  5. When mailbox.open changes and hall.movement is No and mailbox.open is Yes then notify me of new mail

In the history logging of the vibration sensor I can see that there’s an alarm whenever mail is delivered (or when I open/close the door that the mailbox is part of). However, sometimes I won’t get the mail notification (while I have not been in the hall for hours; hall.movement should be No), so I want to debug this setup.

It would be great if I could see the history of variables (at what time they change to which value), but that’s not possible, or is it? (How?)

Any tips on how to debug/improve my flow(s)?

Have you seen the Timeline - Create a notification with flow action?
With that you can write the variables, etc, to the timeline.

There are also some apps that can help:

1 Like

Or take a look at.

1 Like

One option is to use numeric variables as boolean variables. 1=yes 0=no. That way you can trace the operation in insight into some extent

1 Like

Not a tip to log (Thinks the ones above are great, I also use papertrails).

But this flow can go wrong in several ways:
Case1:
Are you sure your vibration alarm does not stop earlier then 10 sec?

0sec: vibration alarm starts
5sec: vibration alarm stops
5sec: mailbox.open is set to No (but it was still No, so no change)
10sec: mailbox.open is set to yes
Line 5 will sent the mail…
But remember your mailbox.open will not be set to no. That trigger has passed

So what happens at the next mail…
0sec: vibration alarm starts
10sec: mailbox.open is set to yes (but it was still yes, so nochange)
15sec: vibration alarm stops
15sec: mailbox.open is set to No
Line 5 will never run… for this mail

The next time your mail will be sent, but the next… might not

Case2:
Are you sure the vibration alarm does not change to stop after exactly 10 sec?

What could happen
0sec: vibration alarm starts
10sec: mailbox.open is set to yes
10sec: vibration alarm stops
10sec: mailbox.open is set to No
Line 5 will not sent the mail…

Chances are small but it can happen…

Why the 10sec? It messes up your timings…
Loose it

1 Like

The “Vibration/Tilt/Drop Alarm Cancellation” times are all set to 30 seconds, so that should be OK?

That is my attempt to catch this use case: when I enter my house through that front door I will first trigger the vibration sensor on the mailbox and only then the motion sensor will detect motion (of either the front door or me stepping in). I hope 10 seconds is enough to catch this use case and stay under the 30 seconds cancellation time.

Suggestions how to better implement this are more then welcome!

The complexity is because I want to achieve this:

  • notification when mail is delivered
  • no notification when I open the door to leave the house
  • no notification when I open the door to enter the house

These sensors are used:

  • Aqara vibration sensor (might trigger alarm in all 3 use cases)
  • Hue indoor motion sensor (triggers alarm when opening/closing the door)

Have to admit I did not think of using the timeline (I only log when there is mail), but I’m afraid logging all flows might clutter up the timeline.

I will start experimenting with Simple LOG and might move to PaperTrails Log if I need more advanced stuff (or just to learn more about SysLog servers, which might be interesting anyway).

1 Like

Split up flow #5
5. When mailbox.open changes Then start flow number 6 after 10 seconds
6. When this flow is started and hall.movement is No and mailbox.open is Yes then notify me of new mail

Correction:
Much better to split flow 1 up. You dont want mailbox.open to give a false warning:

  1. When vibration alarm starts THEN start flow2 after 10 seconds
  2. When this flow is started AND hall.movement is No THEN set variable mailbox.open to Yes (after 10 seconds)
    And flow5 does not need the AND anymore
    1. When mailbox.open changes and mailbox.open is Yes then notify me of new mail

Update: you could even remove the variables (if you motion alarm stays active for 30sec too)

  1. When vibration alarm starts THEN start flow2 after 10 seconds
  2. When this flow is started AND motion alarm is off THEN notify me of new mail

If you created the variable in homey logic. They are traced in the homey insights

1 Like

Standard Logic variables are traced just the same through insights. But just numerical ones, both for Better Logic and default logic. So 0/1 will be visible, false/true will not. Fun fact, the old insights will smooth graph curves and/or take averages, If I look at the graphs, it seems at times I have 1.3 doors open :joy:

What do you mean by old?
Does it mean insights in the new homey web view shows different data then the old insights app.

Did not notice that yet

The data is the same, but the graph library seems different, and you can combine graphs.

Unfortunately that one seems to have a random cancellation time; sometimes only 10 seconds.

(Hence the variable that I only “reset” after a minute)

I’m afraid I’m not sure I understand your improvement suggestions (yet?); not sure what the entire set should look like.

This is the first time I use variables. And only booleans so far. Apparently Boolean variables are not shown in Insights, so I jumped to the wrong conclusion that variables are not shown there at all…

Do you know the card to start a flow?
In When section: image
.
In Then section: image

Yes I know that card.

I’m a bit confused because you gave several suggestions (thanks for that!) and I don’t know which of my flows need to be combined with your suggestions (if any).

Since its unclear after how much time motionsensor cancels keep these flows

  1. When vibration alarm starts THEN after 10 sec start flow 5
    X . When vibration alarm stops. You can remove this flow
  2. When motion sensor alarm starts: set hall.movement to Yes (immediately)
  3. When motion sensor alarm stops: set hall.movement to No (after 1 minute)
  4. When This flow is started and hall.movement is No THEN notify me of new mail

Add papertrails cards to every THEN section to be able to trace

Thanks!

I already added “Simple Log” cards to every THEN section in my original flows to (first) figure out what I’m doing wrong. Once done I can try your simpler (so less error prone?) flow setup.

(to be continued?)

1 Like

Maybe use a door/window sensor on your mailbox in stead of a vibration sensor?
That sensor will not be triggered bij opening the door…

I know

But I have the current sensors already available, so want to see whether they are sufficient to make it work (and have some fun tinkering/learning).

1 Like

I know the feeling…but after trying almost everything I sometimes go for the easy solution…
And buy a sensor for a few euro’s :wink: