Composite Device Tracker Platform

I’m a complete n00b so please forgive me. @pnbruckner thank you for all of your work with Life360, been using it for years. I too have an issue with “Unknown” which causes the automations to trigger in the middle of the night (my wife might kill me for this if I don’t fix it).

I installed Composite, but honestly I don’t know how to tell if it’s working lol. Here’s what I have in my config:

device_tracker:
  - platform: composite
    name: life360_wifename
    time_as: device_or_local
    entity_id:
      - device_tracker.life360_wifename
      - device_tracker.life360_myname

Did I set this up right? I’m just trying to eliminate the automations triggering due to unknown from life360. I only added my wife to the name because it seems she’s triggering that a lot more than I am. Not even sure if I did the “name” right but saw something about adding what you have after the “.” so gave that a try. Looked in the logs and didn’t see anything good or bad about Composite.

You need to create a composite entity for each of you. And you can’t use the same object ID as the “input” entity.

device_tracker:
  - platform: composite
    name: wifename
    time_as: device_or_local
    entity_id:
      - device_tracker.life360_wifename
  - platform: composite
    name: myname
    time_as: device_or_local
    entity_id:
      - device_tracker.life360_myname
1 Like

I’m working on converting this custom integration from a “legacy” device tracker to the newer entity-based implementation, similar to what I recently did with the Life360 integration.

The main reasons to do this are:

  1. Legacy support in the device tracker component could go away at any time.
  2. Move away from the very old known_devices.yaml file to the newer method of storing configuration and entity settings in the .storage folder.
  3. Use a unique ID for the entities so that they can be managed via the Entities page like other entities.

For now, the configuration will still come from YAML files. It will be automatically imported into the .storage folder, and any updates to YAML will automatically update .storage as well. At some point in the future, I’ll probably add the ability to create the entities via the Integrations page. (For now, the imported ones will show up there.) I’ll probably never remove support for YAML configuration.

This time, unlike for what happened with Life360, I’m trying to make the changeover a bit smoother. (I’m a bit freer to do whatever I want!) E.g., it will continue working as before after upgrading (i.e., as a legacy tracker that uses known_devices.yaml), but will issue a deprecation warning about how to modify the YAML configuration to convert to the new implementation. Basically, move the following:

device_tracker:
  - platform: composite
    name: me
    time_as: device_or_local
    entity_id:
      - device_tracker.platform1_me
      - device_tracker.platform2_me
      - binary_sensor.i_am_home

to:

composite:
  trackers:
  - name: me
    time_as: device_or_local
    entity_id:
      - device_tracker.platform1_me
      - device_tracker.platform2_me
      - binary_sensor.i_am_home

At some point I’ll remove support for the old legacy configuration.

If anyone would like to give it a try, you can find the “work in progress” here:

pnbruckner/ha-composite-tracker at entity-based (github.com)

I haven’t updated the readme yet, though.

I’ve done some testing on 2022.10 w/ Python 3.9, but mostly I’ve been testing on 2021.3.3 w/ Python 3.8, since that’s what I’m still using on my “production” system. (Don’t ask! :wink: ) I want to use it on a daily basis to hopefully flush out any bugs I overlooked.

If anyone does give it a try, I’d really appreciate it! Let me know how it works for you, and what versions you’re using. THANKS!

3 Likes

That will be really great!

Sorry for a silly question, I just want to be sure - shall we do it NOW with the CURRENT version? Or is this related to the “work in progress” version you mentioned?

Wait for the new version.

Do you use HACS? I could try publishing a beta release. I think I know how to do that in a way that satisfies HACS, but I haven’t exactly tried it yet. :sweat_smile:

Released 2.4.0b0

This is a prerelease. It adds the newer entity-based implementation, while maintaining (deprecated) support for the original (now called “legacy”) implementation.

I’d be interested to hear how this pre-release works with HACS. And, of course, any feedback, good or bad, if anyone tries it.

Great, gonna install the beta release by HACS and test, thank you !

1 Like

For some reason I’m not finding it in HACS. Nether the existing or the dev version

This integration is not needed any longer as far as I can tell, because you can add multiple device trackers to a person in HA. It pretty much does what this integration intends to: determine the location of a person using multiple sources.

A possibility to add many trackers for a person is present for a long time (at least from September 2020 when I started working with HA).
But this possibility lacks many features available with Composite.

It’s not published, but in theory you can add it as a custom repository, or whatever HACS calls it.

1 Like

Hi. FYI, this custom integration was created long before the built-in person integration existed. I continue to maintain and improve it because, IMHO, it does that job much better than the person integration does and has features the person integration doesn’t.

Obviously though, the person integration has features this doesn’t. However, it can actually fit nicely between the person integration and the various trackers and sensors, so you can take advantage of both.

Whether or not there is an advantage in using this depends on the situation and personal preference.

What situations does the integration handle better? I did not have many problems with the default behaviour, other then the infuriating habit of HA to keep inserting my ipad into the tracked list. But this integration won’t prevent that.

Like these:

  1. Person has a mobile device with more than 1 device tracker (companion app - very very unreliable, Life360, Traccar, …) - are you interested in the latest battery_level?
  2. Person has one mobile phone with gps-based device_tracker platform (like Life360) & some router-based device_tracker platform (like ASUSWRT) - and the person will not be displayed on the map when he is home when NOT using a composite platform.

Have you read the description of what it can do, how it works and its configuration options?

That’s great. It’s always better to use a standard, built-in integration if it suffices for you.

Well, I don’t use the person integration, so I’m not familiar with that “feature.” But, FWIW, you manually configure this custom integration as to which entities it should use as inputs and it doesn’t try to figure that out for you and do something automatically that you don’t want.

@pnbruckner I noticed with your composite integration, that when while one does not see unavailable states anymore, when it goes go unavailable it seems to switch to away, which is equally unhelpful. I wish it would retain the old state (which i thought yours did).

Another thing i noticed is that when having 2 devices as part of a composite tracker, one device fails and the whole tracker fails.

I probably don’t understand exactly how it works yet. I do want to mention that i’m using it by configuring the composite tracker under the person, so i can use that to check, but according to my monitoring of the history entities composite and person show exactly the same, so i don’t think that is influenced in any way.

Any thoughts on this ?

Sorry, that’s hard to follow; too many "it"s. :wink:

Since version 2.2.1 the composite tracker ignores state changes of input entities when the new state of the input entity that changed is unavailable or unknown. So, if an input entity does change to unavailable (or unknown), the state (including GPS coordinates) of the composite tracker should not change. Therefore, if it was not “Away” (i.e., not_home) before that input entity changed to unavailable, it should not change to “Away” when that input entity changes to unavailable.

Are you seeing something different? If so, I’d like to get some details from the log, hopefully with debug enabled.

What do you mean by “fail”?

If you haven’t already done so, please add something like this to your configuration:

logger:
  default: info
  logs:
    custom_components.composite: debug
    homeassistant.core: debug

Then restart HA. When a composite tracker doesn’t behave the way you expect, please find the related messages in home-assistant.log and share them with me. Feel free to PM if you don’t want to share that data publicly. BTW, by enabling debug for homeassistant.core it will also write messages to the log about all entity state changes. Please include the ones that are relevant (i.e., the input entity/entities and the composite entity.)

I did, but it’s hard to tell how that differs from the person integration.

So it seems we both don’t know the difference.

I use HA gps location, Tado gps location and Google GPS location, plus a wifi tracker. Since battery savers tend to kill some apps some time, it is nice to have more. Advantage of the Person integration is that zones count the number of persons in the zone. So I can see my two kids are in the same school, or 4 persons heme…

… which is still possible after adding a composite tracker to a person.