How do I turn an ESPresence MQTT Sensor into a device tracker?

I have a sensor set up that shows my room, but I want to turn that into a device tracker that I can attach to a Person so i can tell if the house is occupied.

I’ve seen other solutions that use the sensors and groups in automations but it would be nice to use the native HA Person object to do it. I want to be able to look at a panel and see who is home and who is away at a glance too.

I have this as an attempt at a device_tracker config in my config.yaml:

  device_tracker:
    - platform: mqtt
      name: stuarts_iphone_at_home
      state_topic: "espresense/devices/espresence_stuarts_iphone/+"
      source_type: bluetooth
      value_template: "{{ topic.split('/')[-1] }}"
      expire_after: 60

but I don’t see a device tracker of that name available after a restart.

device_tracker doesn’t support template as a platform which is a shame because that would work a treat.

This config for the sensor works as expected:

sensor:
    - platform: mqtt_room
      device_id: espresence_stuarts_iphone
      name: ESP Stuarts iPhone
      state_topic: espresense/devices/espresence_stuarts_iphone
      timeout: 60
      away_timeout: 120
      unique_id: espresence_stuarts_iphone
1 Like