Template device_tracker

Just an idea: wouldn’t it be useful to use templates to detect presence? With that we could check multiple entities, and dependent on their state decide if the tracked object is really present. Could be useful where multiple, possibly unreliable trackers are being used. This could already be done using automations, but using a dedicated template-tracker seems more intuitive to me.

By the way, my initial thought was, that the ping-tracker in my opinion rather should be a binary sensor, and a template-tracker could then consume that binary-trackers state.

1 Like

You could group two (or more) trackers in one group and that group’s state changes to ‘home’ if either is at home. If neither is at home, the group changes to ‘not_home’

Does this also work with (binary) sensors? The point of using templates would be, that the source of the information can be of any type.

1 Like

I don’t know about binary sensors, but there’s template binary sensor for that :slight_smile:

And I’m asking, if a presence-group can evaluate the state of a [(template)binary]sensor. :wink:

With a template device tracker like I have in mind I could do something like: if the TV is on and the last motion at place X was (at least) N hours ago, assume person Y to be at home. Yes, that’s really a lot like an automation (which I have already stated above). I just think it may be more intuitive, and there are already a lot of template-based platforms, so why not presence as well? :slight_smile:

2 Likes

This would be very useful, as of now I have a binary sensor that is using the command line to check if I’m home or not.

It would be great to get it displayed as a device_tracker in the frontend. As of now it’s a on/off-status on the front end.

1 Like

Great idea.

This is even more relevant now with the Person component being limited to device trackers.

I, like many others, use Apple Homekit to track my location as it’s more reliable than any other iPhone solution (including the iOS app) - effectively using an automation in HomeKit to flip an input boolean, relying solely on Apple’s native location tracking.

I then use that input_boolean’s state to determine if I’m home or not for other automations. There’s currently no simple way of getting this information into the device_tracker component, and hence the Person component.

I have been using the Apple Homekit Binary Input trick since I have been using Home Assistant.

It would be very helpful to have a template device_tracker. With the ability to consider multiple dis-similar input types I can write the logic to determine the device_trackers state. This would be a wonderful feature to have.

ooh yes please, i’ve been investigating this route too.

I’m currently using a regular sensor template to achieve a sensor.whatevername with the state of home/away

This seems like the new people concept tackles this problem. You can combine multiple sensors to represent the home/away state of a person, such as combining Bluetooth, wifi, and GPS together to determine the presence of a person.

Well yes, but actually no )
Under Person you can combine only different entities of device_tracker platform. And there is no way to make some device_tracker to be home by some input_boolean for example =(

Totally agree, just figured out I’m having the same issue. I would like to ust Fingbox + IFTTT + Nabucasa Webhook to transport and set a custom device tracker. Sounds crazy, but Fingbox detection works well, since it has no local API I need to use IFTTT and to get the information back it would be a webhook…

Anyways having the ability to configure a custom device_tracker.* from a template would be awesone, as status could be change by whatever integration you have/do.

You can do this with the device_tracker.see service https://www.home-assistant.io/components/device_tracker/#device_trackersee-service

simple binary example

automation:
  - id: '123456789'
    alias: Custom Tracker
    trigger:
    - entity_id: binary_sensor.richard
      platform: state
    - event: start
      platform: homeassistant
    action:
    - data_template:
        dev_id: richard
        location_name: >
          {% if is_state('binary_sensor.richard', 'on') -%}
            home
          {%- else -%}
            not_home
          {%- endif %}
      service: device_tracker.see

credit goes to @apop from here: Device tracker from script?

to be clear just helping out @jensihnow so they are not stuck behind this feature request, I still agree a template device tracker would be more intuitive and canonical with other entity types.

5 Likes

I agree a template device tracker is very much desired. I am using Monitor BLE in addition to Router and GPS based trackers and trying to combine them without a template gets very ugly.

The need for this is especially apparent now that we have the person presence detection method as it requires the use of device_tracker entities.

Yeah. I need to create a device tracker from multiple other entities - sensors, two media_players and another device_tracker. And can’t cuz this’ still not implemented :frowning:
This can be solved with implementing template device_tracker. It even can be binary - ‘home’ if template returns True else ‘not_home’

I can only concur, but for those interested, I found a workaround that works for me: I add my ‘virtual device’ in the known_devices.yaml file, then set its value with automations and the device_tracker.see service.
But this solution is at risk, see here.

A viable alternative would be the use of a virtual MQTT device tracker (which doesn’t already use know devices) with the device_tracker.see service

2 Likes

Will it work without setting up MQTT as such? I am not using it.

1 Like

With known_devices.yaml being depreciated, how do you create new device trackers? I want to track/plot my vehicles on a map when we leave them parked. I have a node red flow that detects when I connect/disconnect from my truck, but I want it to then pull my location and save it to an entity to track my truck’s location. But I can’t figure out how to do this without the known_devices config.