From 42653c9b31eb4583c3c791c20ee96e93931b3002 Mon Sep 17 00:00:00 2001 From: Gavin Ni Date: Sun, 14 Apr 2024 13:08:49 -0700 Subject: [PATCH] Clear deprecation warnings --- custom_components/toyota_na/const.py | 12 ++++++------ custom_components/toyota_na/device_tracker.py | 4 ++-- custom_components/toyota_na/manifest.json | 2 +- custom_components/toyota_na/sensor.py | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/custom_components/toyota_na/const.py b/custom_components/toyota_na/const.py index 549acfe..40e4b79 100644 --- a/custom_components/toyota_na/const.py +++ b/custom_components/toyota_na/const.py @@ -2,7 +2,7 @@ from homeassistant.components.binary_sensor import BinarySensorDeviceClass from homeassistant.components.sensor import SensorStateClass -from homeassistant.const import LENGTH_MILES, PERCENTAGE, PRESSURE_PSI +from homeassistant.const import PERCENTAGE, UnitOfPressure from toyota_na.vehicle.base_vehicle import RemoteRequestCommand @@ -161,35 +161,35 @@ "icon": "mdi:car-tire-alert", "feature": VehicleFeatures.FrontDriverTire, "name": "Front Driver Tire", - "unit": PRESSURE_PSI, + "unit": UnitOfPressure.PSI, }, { "state_class": SensorStateClass.MEASUREMENT, "icon": "mdi:car-tire-alert", "feature": VehicleFeatures.FrontPassengerTire, "name": "Front Passenger Tire", - "unit": PRESSURE_PSI, + "unit": UnitOfPressure.PSI, }, { "state_class": SensorStateClass.MEASUREMENT, "icon": "mdi:car-tire-alert", "feature": VehicleFeatures.RearDriverTire, "name": "Rear Driver Tire", - "unit": PRESSURE_PSI, + "unit": UnitOfPressure.PSI, }, { "state_class": SensorStateClass.MEASUREMENT, "icon": "mdi:car-tire-alert", "feature": VehicleFeatures.RearPassengerTire, "name": "Rear Passenger Tire", - "unit": PRESSURE_PSI, + "unit": UnitOfPressure.PSI, }, { "state_class": SensorStateClass.MEASUREMENT, "icon": "mdi:car-tire-alert", "feature": VehicleFeatures.SpareTirePressure, "name": "Spare Tire Pressure", - "unit": PRESSURE_PSI, + "unit": UnitOfPressure.PSI, }, { "state_class": SensorStateClass.MEASUREMENT, diff --git a/custom_components/toyota_na/device_tracker.py b/custom_components/toyota_na/device_tracker.py index 4442c23..3f8c6fe 100644 --- a/custom_components/toyota_na/device_tracker.py +++ b/custom_components/toyota_na/device_tracker.py @@ -5,7 +5,7 @@ from toyota_na.vehicle.base_vehicle import ToyotaVehicle, VehicleFeatures from toyota_na.vehicle.entity_types.ToyotaLocation import ToyotaLocation -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 @@ -81,7 +81,7 @@ def longitude(self): @property def source_type(self): - return SOURCE_TYPE_GPS + return SourceType.GPS @property def available(self): diff --git a/custom_components/toyota_na/manifest.json b/custom_components/toyota_na/manifest.json index 29da98d..9f6dd92 100644 --- a/custom_components/toyota_na/manifest.json +++ b/custom_components/toyota_na/manifest.json @@ -7,6 +7,6 @@ "codeowners": ["@vanstinator, @widewing"], "requirements": ["toyota-na==2.1.1"], "issue_tracker": "https://github.com/widewing/ha-toyota-na/issues", - "version": "2.2.0", + "version": "2.2.1", "iot_class": "cloud_polling" } diff --git a/custom_components/toyota_na/sensor.py b/custom_components/toyota_na/sensor.py index 6aca296..508fa3e 100644 --- a/custom_components/toyota_na/sensor.py +++ b/custom_components/toyota_na/sensor.py @@ -5,7 +5,7 @@ from homeassistant.components.sensor import SensorStateClass from homeassistant.config_entries import ConfigEntry -from homeassistant.const import LENGTH_KILOMETERS, LENGTH_MILES +from homeassistant.const import UnitOfLength from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.update_coordinator import DataUpdateCoordinator @@ -89,8 +89,8 @@ def unit_of_measurement(self): if self._unit_of_measurement == "MI_OR_KM": _unit = cast(ToyotaNumeric, self.feature(self._vehicle_feature)).unit if _unit == "mi": - return LENGTH_MILES + return UnitOfLength.MILES elif _unit == "km": - return LENGTH_KILOMETERS + return UnitOfLength.KILOMETERS return self._unit_of_measurement