MQTT device_tracker changes in 2022.6

I wanted to share the changes I needed to make for HA 2022.6 specific to MQTT device tracking used for presence detection i.e. person state associated with tracked device.

Here are my notes – I hope anyone can correct anything that’s incorrect or if there is a better solution after upgrading:

I could not find a way to use consider_home. Previously using the device_tracker platform for MQTT, you could set that parameter “globally” in your config, for example:

- platform: mqtt
  # Start global setting
  consider_home: 60
  # End global setting
  devices:
    joelp_phone: "tracker/mac/xx:xx:xx:xx:xx:xx"

I use a DIY solution that tracks WiFi clients on my Unifi APs and publishes a retained MQTT message for each client. The payload is home. The retained message allows consistent state between restarts and also avoids a state of unknown when no message is present (i.e. it defaults to away).

What consider_home allowed was a configurable delay in a presence change to away. To make this work for MQTT devices, you had to delete the retained message (i.e. send empty payload) as opposed to sending a payload of not_home. I couldn’t find this behavior documented clearly outside HA source code.

Also, if there is no retained message for the device, the associated person state defaults to unknown. You have to account for this in any automations.

Now that I use the mqtt/device_tracker for my tracked devices, I had to change my solution to send a payload of not_home instead of deleting the retained message.

I hope this helps.

2 Likes