mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Add entity translations to Subaru (#96186)
This commit is contained in:
parent
9a5fe9f644
commit
77f2eb0ac9
@ -58,13 +58,15 @@ class SubaruLock(LockEntity):
|
|||||||
Note that the Subaru API currently does not support returning the status of the locks. Lock status is always unknown.
|
Note that the Subaru API currently does not support returning the status of the locks. Lock status is always unknown.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
_attr_translation_key = "door_locks"
|
||||||
|
|
||||||
def __init__(self, vehicle_info, controller):
|
def __init__(self, vehicle_info, controller):
|
||||||
"""Initialize the locks for the vehicle."""
|
"""Initialize the locks for the vehicle."""
|
||||||
self.controller = controller
|
self.controller = controller
|
||||||
self.vehicle_info = vehicle_info
|
self.vehicle_info = vehicle_info
|
||||||
vin = vehicle_info[VEHICLE_VIN]
|
vin = vehicle_info[VEHICLE_VIN]
|
||||||
self.car_name = vehicle_info[VEHICLE_NAME]
|
self.car_name = vehicle_info[VEHICLE_NAME]
|
||||||
self._attr_name = f"{self.car_name} Door Locks"
|
|
||||||
self._attr_unique_id = f"{vin}_door_locks"
|
self._attr_unique_id = f"{vin}_door_locks"
|
||||||
self._attr_device_info = get_device_info(vehicle_info)
|
self._attr_device_info = get_device_info(vehicle_info)
|
||||||
|
|
||||||
|
@ -55,9 +55,9 @@ KM_PER_MI = DistanceConverter.convert(1, UnitOfLength.MILES, UnitOfLength.KILOME
|
|||||||
SAFETY_SENSORS = [
|
SAFETY_SENSORS = [
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=sc.ODOMETER,
|
key=sc.ODOMETER,
|
||||||
|
translation_key="odometer",
|
||||||
device_class=SensorDeviceClass.DISTANCE,
|
device_class=SensorDeviceClass.DISTANCE,
|
||||||
icon="mdi:road-variant",
|
icon="mdi:road-variant",
|
||||||
name="Odometer",
|
|
||||||
native_unit_of_measurement=UnitOfLength.KILOMETERS,
|
native_unit_of_measurement=UnitOfLength.KILOMETERS,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
@ -67,44 +67,44 @@ SAFETY_SENSORS = [
|
|||||||
API_GEN_2_SENSORS = [
|
API_GEN_2_SENSORS = [
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=sc.AVG_FUEL_CONSUMPTION,
|
key=sc.AVG_FUEL_CONSUMPTION,
|
||||||
|
translation_key="average_fuel_consumption",
|
||||||
icon="mdi:leaf",
|
icon="mdi:leaf",
|
||||||
name="Avg fuel consumption",
|
|
||||||
native_unit_of_measurement=FUEL_CONSUMPTION_LITERS_PER_HUNDRED_KILOMETERS,
|
native_unit_of_measurement=FUEL_CONSUMPTION_LITERS_PER_HUNDRED_KILOMETERS,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=sc.DIST_TO_EMPTY,
|
key=sc.DIST_TO_EMPTY,
|
||||||
|
translation_key="range",
|
||||||
device_class=SensorDeviceClass.DISTANCE,
|
device_class=SensorDeviceClass.DISTANCE,
|
||||||
icon="mdi:gas-station",
|
icon="mdi:gas-station",
|
||||||
name="Range",
|
|
||||||
native_unit_of_measurement=UnitOfLength.KILOMETERS,
|
native_unit_of_measurement=UnitOfLength.KILOMETERS,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=sc.TIRE_PRESSURE_FL,
|
key=sc.TIRE_PRESSURE_FL,
|
||||||
|
translation_key="tire_pressure_front_left",
|
||||||
device_class=SensorDeviceClass.PRESSURE,
|
device_class=SensorDeviceClass.PRESSURE,
|
||||||
name="Tire pressure FL",
|
|
||||||
native_unit_of_measurement=UnitOfPressure.HPA,
|
native_unit_of_measurement=UnitOfPressure.HPA,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=sc.TIRE_PRESSURE_FR,
|
key=sc.TIRE_PRESSURE_FR,
|
||||||
|
translation_key="tire_pressure_front_right",
|
||||||
device_class=SensorDeviceClass.PRESSURE,
|
device_class=SensorDeviceClass.PRESSURE,
|
||||||
name="Tire pressure FR",
|
|
||||||
native_unit_of_measurement=UnitOfPressure.HPA,
|
native_unit_of_measurement=UnitOfPressure.HPA,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=sc.TIRE_PRESSURE_RL,
|
key=sc.TIRE_PRESSURE_RL,
|
||||||
|
translation_key="tire_pressure_rear_left",
|
||||||
device_class=SensorDeviceClass.PRESSURE,
|
device_class=SensorDeviceClass.PRESSURE,
|
||||||
name="Tire pressure RL",
|
|
||||||
native_unit_of_measurement=UnitOfPressure.HPA,
|
native_unit_of_measurement=UnitOfPressure.HPA,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=sc.TIRE_PRESSURE_RR,
|
key=sc.TIRE_PRESSURE_RR,
|
||||||
|
translation_key="tire_pressure_rear_right",
|
||||||
device_class=SensorDeviceClass.PRESSURE,
|
device_class=SensorDeviceClass.PRESSURE,
|
||||||
name="Tire pressure RR",
|
|
||||||
native_unit_of_measurement=UnitOfPressure.HPA,
|
native_unit_of_measurement=UnitOfPressure.HPA,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
@ -114,8 +114,8 @@ API_GEN_2_SENSORS = [
|
|||||||
API_GEN_3_SENSORS = [
|
API_GEN_3_SENSORS = [
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=sc.REMAINING_FUEL_PERCENT,
|
key=sc.REMAINING_FUEL_PERCENT,
|
||||||
|
translation_key="fuel_level",
|
||||||
icon="mdi:gas-station",
|
icon="mdi:gas-station",
|
||||||
name="Fuel level",
|
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
@ -125,23 +125,23 @@ API_GEN_3_SENSORS = [
|
|||||||
EV_SENSORS = [
|
EV_SENSORS = [
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=sc.EV_DISTANCE_TO_EMPTY,
|
key=sc.EV_DISTANCE_TO_EMPTY,
|
||||||
|
translation_key="ev_range",
|
||||||
device_class=SensorDeviceClass.DISTANCE,
|
device_class=SensorDeviceClass.DISTANCE,
|
||||||
icon="mdi:ev-station",
|
icon="mdi:ev-station",
|
||||||
name="EV range",
|
|
||||||
native_unit_of_measurement=UnitOfLength.MILES,
|
native_unit_of_measurement=UnitOfLength.MILES,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=sc.EV_STATE_OF_CHARGE_PERCENT,
|
key=sc.EV_STATE_OF_CHARGE_PERCENT,
|
||||||
|
translation_key="ev_battery_level",
|
||||||
device_class=SensorDeviceClass.BATTERY,
|
device_class=SensorDeviceClass.BATTERY,
|
||||||
name="EV battery level",
|
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=sc.EV_TIME_TO_FULLY_CHARGED_UTC,
|
key=sc.EV_TIME_TO_FULLY_CHARGED_UTC,
|
||||||
|
translation_key="ev_time_to_full_charge",
|
||||||
device_class=SensorDeviceClass.TIMESTAMP,
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
name="EV time to full charge",
|
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -57,6 +57,48 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"entity": {
|
||||||
|
"lock": {
|
||||||
|
"door_locks": {
|
||||||
|
"name": "Door locks"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sensor": {
|
||||||
|
"odometer": {
|
||||||
|
"name": "Odometer"
|
||||||
|
},
|
||||||
|
"average_fuel_consumption": {
|
||||||
|
"name": "Average fuel consumption"
|
||||||
|
},
|
||||||
|
"range": {
|
||||||
|
"name": "Range"
|
||||||
|
},
|
||||||
|
"tire_pressure_front_left": {
|
||||||
|
"name": "Tire pressure front left"
|
||||||
|
},
|
||||||
|
"tire_pressure_front_right": {
|
||||||
|
"name": "Tire pressure front right"
|
||||||
|
},
|
||||||
|
"tire_pressure_rear_left": {
|
||||||
|
"name": "Tire pressure rear left"
|
||||||
|
},
|
||||||
|
"tire_pressure_rear_right": {
|
||||||
|
"name": "Tire pressure rear right"
|
||||||
|
},
|
||||||
|
"fuel_level": {
|
||||||
|
"name": "Fuel level"
|
||||||
|
},
|
||||||
|
"ev_range": {
|
||||||
|
"name": "EV range"
|
||||||
|
},
|
||||||
|
"ev_battery_level": {
|
||||||
|
"name": "EV battery level"
|
||||||
|
},
|
||||||
|
"ev_time_to_full_charge": {
|
||||||
|
"name": "EV time to full charge"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"services": {
|
"services": {
|
||||||
"unlock_specific_door": {
|
"unlock_specific_door": {
|
||||||
"name": "Unlock specific door",
|
"name": "Unlock specific door",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user