Migrate Mazda to new entity naming style (#74939)
This commit is contained in:
parent
d0f71d2e53
commit
53502eb662
11 changed files with 51 additions and 67 deletions
|
@ -32,9 +32,6 @@ from .const import DATA_CLIENT, DATA_COORDINATOR, DOMAIN
|
|||
class MazdaSensorRequiredKeysMixin:
|
||||
"""Mixin for required keys."""
|
||||
|
||||
# Suffix to be appended to the vehicle name to obtain the sensor name
|
||||
name_suffix: str
|
||||
|
||||
# Function to determine the value for this sensor, given the coordinator data and the configured unit system
|
||||
value: Callable[[dict[str, Any], UnitSystem], StateType]
|
||||
|
||||
|
@ -159,7 +156,7 @@ def _ev_remaining_range_value(data, unit_system):
|
|||
SENSOR_ENTITIES = [
|
||||
MazdaSensorEntityDescription(
|
||||
key="fuel_remaining_percentage",
|
||||
name_suffix="Fuel Remaining Percentage",
|
||||
name="Fuel remaining percentage",
|
||||
icon="mdi:gas-station",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -168,7 +165,7 @@ SENSOR_ENTITIES = [
|
|||
),
|
||||
MazdaSensorEntityDescription(
|
||||
key="fuel_distance_remaining",
|
||||
name_suffix="Fuel Distance Remaining",
|
||||
name="Fuel distance remaining",
|
||||
icon="mdi:gas-station",
|
||||
unit=_get_distance_unit,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -177,7 +174,7 @@ SENSOR_ENTITIES = [
|
|||
),
|
||||
MazdaSensorEntityDescription(
|
||||
key="odometer",
|
||||
name_suffix="Odometer",
|
||||
name="Odometer",
|
||||
icon="mdi:speedometer",
|
||||
unit=_get_distance_unit,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
|
@ -186,7 +183,7 @@ SENSOR_ENTITIES = [
|
|||
),
|
||||
MazdaSensorEntityDescription(
|
||||
key="front_left_tire_pressure",
|
||||
name_suffix="Front Left Tire Pressure",
|
||||
name="Front left tire pressure",
|
||||
icon="mdi:car-tire-alert",
|
||||
device_class=SensorDeviceClass.PRESSURE,
|
||||
native_unit_of_measurement=PRESSURE_PSI,
|
||||
|
@ -196,7 +193,7 @@ SENSOR_ENTITIES = [
|
|||
),
|
||||
MazdaSensorEntityDescription(
|
||||
key="front_right_tire_pressure",
|
||||
name_suffix="Front Right Tire Pressure",
|
||||
name="Front right tire pressure",
|
||||
icon="mdi:car-tire-alert",
|
||||
device_class=SensorDeviceClass.PRESSURE,
|
||||
native_unit_of_measurement=PRESSURE_PSI,
|
||||
|
@ -206,7 +203,7 @@ SENSOR_ENTITIES = [
|
|||
),
|
||||
MazdaSensorEntityDescription(
|
||||
key="rear_left_tire_pressure",
|
||||
name_suffix="Rear Left Tire Pressure",
|
||||
name="Rear left tire pressure",
|
||||
icon="mdi:car-tire-alert",
|
||||
device_class=SensorDeviceClass.PRESSURE,
|
||||
native_unit_of_measurement=PRESSURE_PSI,
|
||||
|
@ -216,7 +213,7 @@ SENSOR_ENTITIES = [
|
|||
),
|
||||
MazdaSensorEntityDescription(
|
||||
key="rear_right_tire_pressure",
|
||||
name_suffix="Rear Right Tire Pressure",
|
||||
name="Rear right tire pressure",
|
||||
icon="mdi:car-tire-alert",
|
||||
device_class=SensorDeviceClass.PRESSURE,
|
||||
native_unit_of_measurement=PRESSURE_PSI,
|
||||
|
@ -226,7 +223,7 @@ SENSOR_ENTITIES = [
|
|||
),
|
||||
MazdaSensorEntityDescription(
|
||||
key="ev_charge_level",
|
||||
name_suffix="Charge Level",
|
||||
name="Charge level",
|
||||
device_class=SensorDeviceClass.BATTERY,
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -235,7 +232,7 @@ SENSOR_ENTITIES = [
|
|||
),
|
||||
MazdaSensorEntityDescription(
|
||||
key="ev_remaining_range",
|
||||
name_suffix="Remaining Range",
|
||||
name="Remaining range",
|
||||
icon="mdi:ev-station",
|
||||
unit=_get_distance_unit,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -276,7 +273,6 @@ class MazdaSensorEntity(MazdaEntity, SensorEntity):
|
|||
super().__init__(client, coordinator, index)
|
||||
self.entity_description = description
|
||||
|
||||
self._attr_name = f"{self.vehicle_name} {description.name_suffix}"
|
||||
self._attr_unique_id = f"{self.vin}_{description.key}"
|
||||
|
||||
@property
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue