mirror of
https://github.com/home-assistant/developers.home-assistant.git
synced 2025-07-18 23:06:31 +00:00
Change the location_accuracy type for the DeviceTracker entity class to float (#2653)
This commit is contained in:
parent
6702464eab
commit
42376bda5b
27
blog/2025-04-24-device-tracker-accuracy.md
Normal file
27
blog/2025-04-24-device-tracker-accuracy.md
Normal 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
|
||||||
|
```
|
@ -48,7 +48,7 @@ Properties should always only return information from memory and not do I/O (lik
|
|||||||
| ----------------- | ------------------------------ | ---------------- | ---------------------------------------- |
|
| ----------------- | ------------------------------ | ---------------- | ---------------------------------------- |
|
||||||
| battery_level | <code>int | None</code> | `None` | The battery level of the device. |
|
| battery_level | <code>int | None</code> | `None` | The battery level of the device. |
|
||||||
| latitude | <code>float | None</code> | `None` | The latitude coordinate of the device. |
|
| latitude | <code>float | 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 | None</code> | `None` | The location name of the device. |
|
| location_name | <code>str | None</code> | `None` | The location name of the device. |
|
||||||
| longitude | <code>float | None</code> | `None` | The longitude coordinate of the device. |
|
| longitude | <code>float | None</code> | `None` | The longitude coordinate of the device. |
|
||||||
| source_type | SourceType | `SourceType.GPS` | The source type of the device. |
|
| source_type | SourceType | `SourceType.GPS` | The source type of the device. |
|
||||||
|
Loading…
x
Reference in New Issue
Block a user