Skip to content

Commit

Permalink
take care of deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasbrett committed Mar 6, 2024
1 parent e2a8e80 commit 9fdda51
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions custom_components/biketrax/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Literal

from aiobiketrax import Device
from homeassistant.components.device_tracker import SOURCE_TYPE_GPS
from homeassistant.components.device_tracker import SourceType
from homeassistant.components.device_tracker.config_entry import TrackerEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
Expand Down Expand Up @@ -82,7 +82,7 @@ def location_accuracy(self) -> int:
@property
def source_type(self) -> Literal["gps"]:
"""Return the source type, e.g. gps or router, of the device."""
return SOURCE_TYPE_GPS
return SourceType.GPS

@property
def extra_state_attributes(self):
Expand Down
11 changes: 5 additions & 6 deletions custom_components/biketrax/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
LENGTH_KILOMETERS,
LENGTH_METERS,
UnitOfLength,
PERCENTAGE,
SPEED_KILOMETERS_PER_HOUR,
UnitOfSpeed,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory
Expand Down Expand Up @@ -62,7 +61,7 @@ class BikeTraxSensorEntityDescription(
icon="mdi:speedometer",
key="total_distance",
name="Total distance",
native_unit_of_measurement=LENGTH_KILOMETERS,
native_unit_of_measurement=UnitOfLength.KILOMETERS,
state_class=SensorStateClass.TOTAL_INCREASING,
),
BikeTraxSensorEntityDescription(
Expand All @@ -71,7 +70,7 @@ class BikeTraxSensorEntityDescription(
icon="mdi:speedometer",
key="speed",
name="Current speed",
native_unit_of_measurement=SPEED_KILOMETERS_PER_HOUR,
native_unit_of_measurement=UnitOfSpeed.KILOMETERS_PER_HOUR,
state_class=SensorStateClass.MEASUREMENT,
),
BikeTraxSensorEntityDescription(
Expand Down Expand Up @@ -106,7 +105,7 @@ class BikeTraxSensorEntityDescription(
icon="mdi:map-marker-distance",
key="geofence_radius",
name="Auto alarm geofence radius",
native_unit_of_measurement=LENGTH_METERS,
native_unit_of_measurement=UnitOfLength.METERS,
),
BikeTraxSensorEntityDescription(
coordinator=DATA_DEVICE,
Expand Down

0 comments on commit 9fdda51

Please sign in to comment.