From c5a1a8034e49d2d23d9f55e32316ffcde7f419ae Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 25 Sep 2024 08:31:37 +0200 Subject: [PATCH] Document device tracker shorthand attributes and EntityDescription changes (#2333) Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- ...40924-device-tracker-entity-description.md | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 blog/20240924-device-tracker-entity-description.md diff --git a/blog/20240924-device-tracker-entity-description.md b/blog/20240924-device-tracker-entity-description.md new file mode 100644 index 00000000..e8e4725b --- /dev/null +++ b/blog/20240924-device-tracker-entity-description.md @@ -0,0 +1,23 @@ +--- +author: epenet +authorURL: https://github.com/epenet +title: "Enforce SourceType and add shorthand attributes and EntityDescription to device_tracker" +--- + +The `source_type` property of device_tracker entities is now always expected to be a `SourceType` enum value. Standard strings are no longer valid. + +`TrackerEntity` and `ScannerEntity` now have a dedicated `ScannerEntityDescription` and `TrackerEntityDescription`, which need to be used as base class when associating an `EntityDescription` to the `Entity`. + +The `source_type` for these entities now also defaults to `SourceType.GPS` and `SourceType.ROUTER`, and it may be possible to drop the overriding property. + +The following shorthand attributes have also been added: +- `BaseTrackerEntity._attr_source_type` +- `TrackerEntity._attr_latitude` +- `TrackerEntity._attr_location_accuracy` +- `TrackerEntity._attr_location_name` +- `TrackerEntity._attr_longitude` +- `TrackerEntity._attr_source_type` (defaults to `SourceType.GPS`) +- `ScannerEntity._attr_hostname` +- `ScannerEntity._attr_ip_address` +- `ScannerEntity._attr_mac_address` +- `ScannerEntity._attr_source_type` (defaults to `SourceType.ROUTER`)