mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Add entity translations for Mazda (#95729)
* Add entity translations for Mazda * Use references
This commit is contained in:
parent
5d3039f21e
commit
b53df429fa
@ -46,49 +46,49 @@ def _plugged_in_supported(data):
|
||||
BINARY_SENSOR_ENTITIES = [
|
||||
MazdaBinarySensorEntityDescription(
|
||||
key="driver_door",
|
||||
name="Driver door",
|
||||
translation_key="driver_door",
|
||||
icon="mdi:car-door",
|
||||
device_class=BinarySensorDeviceClass.DOOR,
|
||||
value_fn=lambda data: data["status"]["doors"]["driverDoorOpen"],
|
||||
),
|
||||
MazdaBinarySensorEntityDescription(
|
||||
key="passenger_door",
|
||||
name="Passenger door",
|
||||
translation_key="passenger_door",
|
||||
icon="mdi:car-door",
|
||||
device_class=BinarySensorDeviceClass.DOOR,
|
||||
value_fn=lambda data: data["status"]["doors"]["passengerDoorOpen"],
|
||||
),
|
||||
MazdaBinarySensorEntityDescription(
|
||||
key="rear_left_door",
|
||||
name="Rear left door",
|
||||
translation_key="rear_left_door",
|
||||
icon="mdi:car-door",
|
||||
device_class=BinarySensorDeviceClass.DOOR,
|
||||
value_fn=lambda data: data["status"]["doors"]["rearLeftDoorOpen"],
|
||||
),
|
||||
MazdaBinarySensorEntityDescription(
|
||||
key="rear_right_door",
|
||||
name="Rear right door",
|
||||
translation_key="rear_right_door",
|
||||
icon="mdi:car-door",
|
||||
device_class=BinarySensorDeviceClass.DOOR,
|
||||
value_fn=lambda data: data["status"]["doors"]["rearRightDoorOpen"],
|
||||
),
|
||||
MazdaBinarySensorEntityDescription(
|
||||
key="trunk",
|
||||
name="Trunk",
|
||||
translation_key="trunk",
|
||||
icon="mdi:car-back",
|
||||
device_class=BinarySensorDeviceClass.DOOR,
|
||||
value_fn=lambda data: data["status"]["doors"]["trunkOpen"],
|
||||
),
|
||||
MazdaBinarySensorEntityDescription(
|
||||
key="hood",
|
||||
name="Hood",
|
||||
translation_key="hood",
|
||||
icon="mdi:car",
|
||||
device_class=BinarySensorDeviceClass.DOOR,
|
||||
value_fn=lambda data: data["status"]["doors"]["hoodOpen"],
|
||||
),
|
||||
MazdaBinarySensorEntityDescription(
|
||||
key="ev_plugged_in",
|
||||
name="Plugged in",
|
||||
translation_key="ev_plugged_in",
|
||||
device_class=BinarySensorDeviceClass.PLUG,
|
||||
is_supported=_plugged_in_supported,
|
||||
value_fn=lambda data: data["evStatus"]["chargeInfo"]["pluggedIn"],
|
||||
|
@ -76,31 +76,31 @@ class MazdaButtonEntityDescription(ButtonEntityDescription):
|
||||
BUTTON_ENTITIES = [
|
||||
MazdaButtonEntityDescription(
|
||||
key="start_engine",
|
||||
name="Start engine",
|
||||
translation_key="start_engine",
|
||||
icon="mdi:engine",
|
||||
is_supported=lambda data: not data["isElectric"],
|
||||
),
|
||||
MazdaButtonEntityDescription(
|
||||
key="stop_engine",
|
||||
name="Stop engine",
|
||||
translation_key="stop_engine",
|
||||
icon="mdi:engine-off",
|
||||
is_supported=lambda data: not data["isElectric"],
|
||||
),
|
||||
MazdaButtonEntityDescription(
|
||||
key="turn_on_hazard_lights",
|
||||
name="Turn on hazard lights",
|
||||
translation_key="turn_on_hazard_lights",
|
||||
icon="mdi:hazard-lights",
|
||||
is_supported=lambda data: not data["isElectric"],
|
||||
),
|
||||
MazdaButtonEntityDescription(
|
||||
key="turn_off_hazard_lights",
|
||||
name="Turn off hazard lights",
|
||||
translation_key="turn_off_hazard_lights",
|
||||
icon="mdi:hazard-lights",
|
||||
is_supported=lambda data: not data["isElectric"],
|
||||
),
|
||||
MazdaButtonEntityDescription(
|
||||
key="refresh_vehicle_status",
|
||||
name="Refresh status",
|
||||
translation_key="refresh_vehicle_status",
|
||||
icon="mdi:refresh",
|
||||
async_press=handle_refresh_vehicle_status,
|
||||
is_supported=lambda data: data["isElectric"],
|
||||
|
@ -66,7 +66,7 @@ async def async_setup_entry(
|
||||
class MazdaClimateEntity(MazdaEntity, ClimateEntity):
|
||||
"""Class for a Mazda climate entity."""
|
||||
|
||||
_attr_name = "Climate"
|
||||
_attr_translation_key = "climate"
|
||||
_attr_supported_features = (
|
||||
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
|
||||
)
|
||||
|
@ -28,7 +28,7 @@ async def async_setup_entry(
|
||||
class MazdaDeviceTracker(MazdaEntity, TrackerEntity):
|
||||
"""Class for the device tracker."""
|
||||
|
||||
_attr_name = "Device tracker"
|
||||
_attr_translation_key = "device_tracker"
|
||||
_attr_icon = "mdi:car"
|
||||
_attr_force_update = False
|
||||
|
||||
|
@ -32,7 +32,7 @@ async def async_setup_entry(
|
||||
class MazdaLock(MazdaEntity, LockEntity):
|
||||
"""Class for the lock."""
|
||||
|
||||
_attr_name = "Lock"
|
||||
_attr_translation_key = "lock"
|
||||
|
||||
def __init__(self, client, coordinator, index) -> None:
|
||||
"""Initialize Mazda lock."""
|
||||
|
@ -135,7 +135,7 @@ def _ev_remaining_range_value(data):
|
||||
SENSOR_ENTITIES = [
|
||||
MazdaSensorEntityDescription(
|
||||
key="fuel_remaining_percentage",
|
||||
name="Fuel remaining percentage",
|
||||
translation_key="fuel_remaining_percentage",
|
||||
icon="mdi:gas-station",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
@ -144,7 +144,7 @@ SENSOR_ENTITIES = [
|
||||
),
|
||||
MazdaSensorEntityDescription(
|
||||
key="fuel_distance_remaining",
|
||||
name="Fuel distance remaining",
|
||||
translation_key="fuel_distance_remaining",
|
||||
icon="mdi:gas-station",
|
||||
device_class=SensorDeviceClass.DISTANCE,
|
||||
native_unit_of_measurement=UnitOfLength.KILOMETERS,
|
||||
@ -154,7 +154,7 @@ SENSOR_ENTITIES = [
|
||||
),
|
||||
MazdaSensorEntityDescription(
|
||||
key="odometer",
|
||||
name="Odometer",
|
||||
translation_key="odometer",
|
||||
icon="mdi:speedometer",
|
||||
device_class=SensorDeviceClass.DISTANCE,
|
||||
native_unit_of_measurement=UnitOfLength.KILOMETERS,
|
||||
@ -164,7 +164,7 @@ SENSOR_ENTITIES = [
|
||||
),
|
||||
MazdaSensorEntityDescription(
|
||||
key="front_left_tire_pressure",
|
||||
name="Front left tire pressure",
|
||||
translation_key="front_left_tire_pressure",
|
||||
icon="mdi:car-tire-alert",
|
||||
device_class=SensorDeviceClass.PRESSURE,
|
||||
native_unit_of_measurement=UnitOfPressure.PSI,
|
||||
@ -174,7 +174,7 @@ SENSOR_ENTITIES = [
|
||||
),
|
||||
MazdaSensorEntityDescription(
|
||||
key="front_right_tire_pressure",
|
||||
name="Front right tire pressure",
|
||||
translation_key="front_right_tire_pressure",
|
||||
icon="mdi:car-tire-alert",
|
||||
device_class=SensorDeviceClass.PRESSURE,
|
||||
native_unit_of_measurement=UnitOfPressure.PSI,
|
||||
@ -184,7 +184,7 @@ SENSOR_ENTITIES = [
|
||||
),
|
||||
MazdaSensorEntityDescription(
|
||||
key="rear_left_tire_pressure",
|
||||
name="Rear left tire pressure",
|
||||
translation_key="rear_left_tire_pressure",
|
||||
icon="mdi:car-tire-alert",
|
||||
device_class=SensorDeviceClass.PRESSURE,
|
||||
native_unit_of_measurement=UnitOfPressure.PSI,
|
||||
@ -194,7 +194,7 @@ SENSOR_ENTITIES = [
|
||||
),
|
||||
MazdaSensorEntityDescription(
|
||||
key="rear_right_tire_pressure",
|
||||
name="Rear right tire pressure",
|
||||
translation_key="rear_right_tire_pressure",
|
||||
icon="mdi:car-tire-alert",
|
||||
device_class=SensorDeviceClass.PRESSURE,
|
||||
native_unit_of_measurement=UnitOfPressure.PSI,
|
||||
@ -204,7 +204,7 @@ SENSOR_ENTITIES = [
|
||||
),
|
||||
MazdaSensorEntityDescription(
|
||||
key="ev_charge_level",
|
||||
name="Charge level",
|
||||
translation_key="ev_charge_level",
|
||||
device_class=SensorDeviceClass.BATTERY,
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
@ -213,7 +213,7 @@ SENSOR_ENTITIES = [
|
||||
),
|
||||
MazdaSensorEntityDescription(
|
||||
key="ev_remaining_range",
|
||||
name="Remaining range",
|
||||
translation_key="ev_remaining_range",
|
||||
icon="mdi:ev-station",
|
||||
device_class=SensorDeviceClass.DISTANCE,
|
||||
native_unit_of_measurement=UnitOfLength.KILOMETERS,
|
||||
|
@ -21,6 +21,97 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"binary_sensor": {
|
||||
"driver_door": {
|
||||
"name": "Driver door"
|
||||
},
|
||||
"passenger_door": {
|
||||
"name": "Passenger door"
|
||||
},
|
||||
"rear_left_door": {
|
||||
"name": "Rear left door"
|
||||
},
|
||||
"rear_right_door": {
|
||||
"name": "Rear right door"
|
||||
},
|
||||
"trunk": {
|
||||
"name": "Trunk"
|
||||
},
|
||||
"hood": {
|
||||
"name": "Hood"
|
||||
},
|
||||
"ev_plugged_in": {
|
||||
"name": "Plugged in"
|
||||
}
|
||||
},
|
||||
"button": {
|
||||
"start_engine": {
|
||||
"name": "Start engine"
|
||||
},
|
||||
"stop_engine": {
|
||||
"name": "Stop engine"
|
||||
},
|
||||
"turn_on_hazard_lights": {
|
||||
"name": "Turn on hazard lights"
|
||||
},
|
||||
"turn_off_hazard_lights": {
|
||||
"name": "Turn off hazard lights"
|
||||
},
|
||||
"refresh_vehicle_status": {
|
||||
"name": "Refresh status"
|
||||
}
|
||||
},
|
||||
"climate": {
|
||||
"climate": {
|
||||
"name": "[%key:component::climate::title%]"
|
||||
}
|
||||
},
|
||||
"device_tracker": {
|
||||
"device_tracker": {
|
||||
"name": "[%key:component::device_tracker::title%]"
|
||||
}
|
||||
},
|
||||
"lock": {
|
||||
"lock": {
|
||||
"name": "[%key:component::lock::title%]"
|
||||
}
|
||||
},
|
||||
"sensor": {
|
||||
"fuel_remaining_percentage": {
|
||||
"name": "Fuel remaining percentage"
|
||||
},
|
||||
"fuel_distance_remaining": {
|
||||
"name": "Fuel distance remaining"
|
||||
},
|
||||
"odometer": {
|
||||
"name": "Odometer"
|
||||
},
|
||||
"front_left_tire_pressure": {
|
||||
"name": "Front left tire pressure"
|
||||
},
|
||||
"front_right_tire_pressure": {
|
||||
"name": "Front right tire pressure"
|
||||
},
|
||||
"rear_left_tire_pressure": {
|
||||
"name": "Rear left tire pressure"
|
||||
},
|
||||
"rear_right_tire_pressure": {
|
||||
"name": "Rear right tire pressure"
|
||||
},
|
||||
"ev_charge_level": {
|
||||
"name": "Charge level"
|
||||
},
|
||||
"ev_remaining_range": {
|
||||
"name": "Remaining range"
|
||||
}
|
||||
},
|
||||
"switch": {
|
||||
"charging": {
|
||||
"name": "Charging"
|
||||
}
|
||||
}
|
||||
},
|
||||
"services": {
|
||||
"send_poi": {
|
||||
"name": "Send POI",
|
||||
|
@ -32,7 +32,7 @@ async def async_setup_entry(
|
||||
class MazdaChargingSwitch(MazdaEntity, SwitchEntity):
|
||||
"""Class for the charging switch."""
|
||||
|
||||
_attr_name = "Charging"
|
||||
_attr_translation_key = "charging"
|
||||
_attr_icon = "mdi:ev-station"
|
||||
|
||||
def __init__(
|
||||
|
Loading…
x
Reference in New Issue
Block a user