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:
- Legacy support in the device tracker component could go away at any time.
- Move away from the very old known_devices.yaml file to the newer method of storing configuration and entity settings in the .storage folder.
- 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! ) 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!