Change the location_accuracy type for the DeviceTracker entity class to float (#2653)

This commit is contained in:
Jan Bouwhuis 2025-04-24 23:12:03 +02:00 committed by GitHub
parent 6702464eab
commit 42376bda5b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 1 deletions

View File

@ -0,0 +1,27 @@
---
author: Jan Bouwhuis
authorURL: https://github.com/jbouwh
authorImageURL: https://avatars.githubusercontent.com/u/7188918?s=96&v=4
title: Device tracker TrackerEntity location accuracy attribute type change
---
The type of `location_accuracy` attribute (short hand `_attr_location_accuracy`) of the `TrackerEntity` class of the `device_tracker` entity component has been changed from `int` to `float`.
Type conversions in case the source value is a `float` are no longer needed.
### Example
```python
class ExampleTrackerEntity(TrackerEntity):
"""Test tracker entity."""
_attr_location_accuracy: float = 2.5
@cached_property
def location_accuracy(self) -> float:
"""Return the location accuracy of the device.
Value in meters.
"""
return self._attr_location_accuracy
```

View File

@ -48,7 +48,7 @@ Properties should always only return information from memory and not do I/O (lik
| ----------------- | ------------------------------ | ---------------- | ---------------------------------------- |
| battery_level | <code>int &#124; None</code> | `None` | The battery level of the device. |
| latitude | <code>float &#124; None</code> | `None` | The latitude coordinate of the device. |
| location_accuracy | `int` | `0` | The location accuracy (m) of the device. |
| location_accuracy | `float` | `0` | The location accuracy (m) of the device. |
| location_name | <code>str &#124; None</code> | `None` | The location name of the device. |
| longitude | <code>float &#124; None</code> | `None` | The longitude coordinate of the device. |
| source_type | SourceType | `SourceType.GPS` | The source type of the device. |