Optimize flow Room Presense

Currently, i’m working on detecting which Homey user is in which room, based on their smartwatch.

To accomplish this, I’m using ESPresense, which sends MQTT to Homey and I’ve now set up the following test flow, currently only for 1 User and 2 rooms.

Although this is working fine, it’s already a tiny bit slow (15-20 sec delay compared to the MQTT sent from the ESPresense)

Since more “rooms/devices” will be added, and therefore the flow will become more complex, cause it needs to compare variables (users/rooms) against more other variables etc.

Does anyone have a great idea on how to optimize this, and/or make the flows less complex?
Or am I just on the right track and will adding more devices/rooms probably not decrease performance too much?

Do you mean, when you add a log card with timestamp (like Simple Log) to the triggercard, the action cards are fired 15-20s later?
That would be really odd.
What’s does the rest of the flow look like?

yep, but it’s measured from the moment the MQTT is sent (not received), still need to put some more logs in to test where that delay is actually coming from. Just thought I might just already put the question up here, cause some people might have brilliant ideas :+1:

The rest of the flow will be starting other flows, but since this is just a test setup it’s just writing to the log for now.

Ah OK. The writing and comparing of variables should take a number of ms (not seconds).

The first two cards in the two rows look equal to me?
How do you filter on ESPR-BRF and -Storage?

Also just noticed that the MQTT client card shows as “Unavailable” in the flow at times, then shows up a few seconds later, so that might also be causing the 15-20 sec delay…

UPDATE: Unavailable was due to the MQTT Client app crashing because of Homey CPU issues??? Did a restart of the app, which did not resolve it, restarted Homey, red ring and crashed during boot, after a reset from yesterday’s backup it all seems to be working for now, still has a delay, but doesn’t seem to be increasing much by adding more ESP’s.

They look the same (Number 1), but it’s actually 2 different values within different variables that are set within Better Logic, need to have a look at how I can name those values. It’s set by the Json handler.

Yeah it’s confusing haha, but for the test setup it works :slight_smile:
If you know how to rename them, please let me know, saves me some time to look into that later

Or did you mean the MQTT card, that is actually not the same either, it is a MQTT received per ESPresense device, but since the topic contained the device ID i removed that part after the IRK.
So the first flow should say IRK: ID / BRF and the second one IRK ID / Storage.

Yes, this. So they’re not equal :wink:

Yes, the 2 rooms each have an ESP32, which sends out a different MQTT topic.
The delays seem to come from the MQTT Client, not really figured out why yet, so need to dig into that a bit more.

I use MQTT a lot and I didn’t came across any major delays, like several seconds, yet

“Unavailable” should mean the app gets paused at times in some way.
You can use this test flow to see what’s going on, and at what times and how many times

Of course you can use a timeline card, but I like SimpleLog because you can view the errors filtered (on app name f.i.), which is not possible with the timeline.

An other way is to view the logs per app settings:

1 Like