Add entity translations to BMW Connected Drive (#95142)
parent
d95c241a1a
commit
844a1ebbc6
|
@ -123,7 +123,7 @@ class BMWBinarySensorEntityDescription(
|
|||
SENSOR_TYPES: tuple[BMWBinarySensorEntityDescription, ...] = (
|
||||
BMWBinarySensorEntityDescription(
|
||||
key="lids",
|
||||
name="Lids",
|
||||
translation_key="lids",
|
||||
device_class=BinarySensorDeviceClass.OPENING,
|
||||
icon="mdi:car-door-lock",
|
||||
# device class opening: On means open, Off means closed
|
||||
|
@ -134,7 +134,7 @@ SENSOR_TYPES: tuple[BMWBinarySensorEntityDescription, ...] = (
|
|||
),
|
||||
BMWBinarySensorEntityDescription(
|
||||
key="windows",
|
||||
name="Windows",
|
||||
translation_key="windows",
|
||||
device_class=BinarySensorDeviceClass.OPENING,
|
||||
icon="mdi:car-door",
|
||||
# device class opening: On means open, Off means closed
|
||||
|
@ -145,7 +145,7 @@ SENSOR_TYPES: tuple[BMWBinarySensorEntityDescription, ...] = (
|
|||
),
|
||||
BMWBinarySensorEntityDescription(
|
||||
key="door_lock_state",
|
||||
name="Door lock state",
|
||||
translation_key="door_lock_state",
|
||||
device_class=BinarySensorDeviceClass.LOCK,
|
||||
icon="mdi:car-key",
|
||||
# device class lock: On means unlocked, Off means locked
|
||||
|
@ -158,7 +158,7 @@ SENSOR_TYPES: tuple[BMWBinarySensorEntityDescription, ...] = (
|
|||
),
|
||||
BMWBinarySensorEntityDescription(
|
||||
key="condition_based_services",
|
||||
name="Condition based services",
|
||||
translation_key="condition_based_services",
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
icon="mdi:wrench",
|
||||
# device class problem: On means problem detected, Off means no problem
|
||||
|
@ -167,7 +167,7 @@ SENSOR_TYPES: tuple[BMWBinarySensorEntityDescription, ...] = (
|
|||
),
|
||||
BMWBinarySensorEntityDescription(
|
||||
key="check_control_messages",
|
||||
name="Check control messages",
|
||||
translation_key="check_control_messages",
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
icon="mdi:car-tire-alert",
|
||||
# device class problem: On means problem detected, Off means no problem
|
||||
|
@ -177,7 +177,7 @@ SENSOR_TYPES: tuple[BMWBinarySensorEntityDescription, ...] = (
|
|||
# electric
|
||||
BMWBinarySensorEntityDescription(
|
||||
key="charging_status",
|
||||
name="Charging status",
|
||||
translation_key="charging_status",
|
||||
device_class=BinarySensorDeviceClass.BATTERY_CHARGING,
|
||||
icon="mdi:ev-station",
|
||||
# device class power: On means power detected, Off means no power
|
||||
|
@ -185,14 +185,14 @@ SENSOR_TYPES: tuple[BMWBinarySensorEntityDescription, ...] = (
|
|||
),
|
||||
BMWBinarySensorEntityDescription(
|
||||
key="connection_status",
|
||||
name="Connection status",
|
||||
translation_key="connection_status",
|
||||
device_class=BinarySensorDeviceClass.PLUG,
|
||||
icon="mdi:car-electric",
|
||||
value_fn=lambda v: v.fuel_and_battery.is_charger_connected,
|
||||
),
|
||||
BMWBinarySensorEntityDescription(
|
||||
key="is_pre_entry_climatization_enabled",
|
||||
name="Pre entry climatization",
|
||||
translation_key="is_pre_entry_climatization_enabled",
|
||||
icon="mdi:car-seat-heater",
|
||||
value_fn=lambda v: v.charging_profile.is_pre_entry_climatization_enabled
|
||||
if v.charging_profile
|
||||
|
|
|
@ -37,32 +37,32 @@ class BMWButtonEntityDescription(ButtonEntityDescription):
|
|||
BUTTON_TYPES: tuple[BMWButtonEntityDescription, ...] = (
|
||||
BMWButtonEntityDescription(
|
||||
key="light_flash",
|
||||
translation_key="light_flash",
|
||||
icon="mdi:car-light-alert",
|
||||
name="Flash lights",
|
||||
remote_function=lambda vehicle: vehicle.remote_services.trigger_remote_light_flash(),
|
||||
),
|
||||
BMWButtonEntityDescription(
|
||||
key="sound_horn",
|
||||
translation_key="sound_horn",
|
||||
icon="mdi:bullhorn",
|
||||
name="Sound horn",
|
||||
remote_function=lambda vehicle: vehicle.remote_services.trigger_remote_horn(),
|
||||
),
|
||||
BMWButtonEntityDescription(
|
||||
key="activate_air_conditioning",
|
||||
translation_key="activate_air_conditioning",
|
||||
icon="mdi:hvac",
|
||||
name="Activate air conditioning",
|
||||
remote_function=lambda vehicle: vehicle.remote_services.trigger_remote_air_conditioning(),
|
||||
),
|
||||
BMWButtonEntityDescription(
|
||||
key="find_vehicle",
|
||||
translation_key="find_vehicle",
|
||||
icon="mdi:crosshairs-question",
|
||||
name="Find vehicle",
|
||||
remote_function=lambda vehicle: vehicle.remote_services.trigger_remote_vehicle_finder(),
|
||||
),
|
||||
BMWButtonEntityDescription(
|
||||
key="refresh",
|
||||
translation_key="refresh",
|
||||
icon="mdi:refresh",
|
||||
name="Refresh from cloud",
|
||||
account_function=lambda coordinator: coordinator.async_request_refresh(),
|
||||
enabled_when_read_only=True,
|
||||
),
|
||||
|
|
|
@ -44,7 +44,7 @@ async def async_setup_entry(
|
|||
class BMWLock(BMWBaseEntity, LockEntity):
|
||||
"""Representation of a MyBMW vehicle lock."""
|
||||
|
||||
_attr_name = "Lock"
|
||||
_attr_translation_key = "lock"
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
|
|
@ -45,7 +45,7 @@ class BMWNumberEntityDescription(NumberEntityDescription, BMWRequiredKeysMixin):
|
|||
NUMBER_TYPES: list[BMWNumberEntityDescription] = [
|
||||
BMWNumberEntityDescription(
|
||||
key="target_soc",
|
||||
name="Target SoC",
|
||||
translation_key="target_soc",
|
||||
device_class=NumberDeviceClass.BATTERY,
|
||||
is_available=lambda v: v.is_remote_set_target_soc_enabled,
|
||||
native_max_value=100.0,
|
||||
|
|
|
@ -39,7 +39,7 @@ class BMWSelectEntityDescription(SelectEntityDescription, BMWRequiredKeysMixin):
|
|||
SELECT_TYPES: dict[str, BMWSelectEntityDescription] = {
|
||||
"ac_limit": BMWSelectEntityDescription(
|
||||
key="ac_limit",
|
||||
name="AC Charging Limit",
|
||||
translation_key="ac_limit",
|
||||
is_available=lambda v: v.is_remote_set_ac_limit_enabled,
|
||||
dynamic_options=lambda v: [
|
||||
str(lim) for lim in v.charging_profile.ac_available_limits # type: ignore[union-attr]
|
||||
|
@ -53,7 +53,7 @@ SELECT_TYPES: dict[str, BMWSelectEntityDescription] = {
|
|||
),
|
||||
"charging_mode": BMWSelectEntityDescription(
|
||||
key="charging_mode",
|
||||
name="Charging Mode",
|
||||
translation_key="charging_mode",
|
||||
is_available=lambda v: v.is_charging_plan_supported,
|
||||
options=[c.value for c in ChargingMode if c != ChargingMode.UNKNOWN],
|
||||
current_option=lambda v: str(v.charging_profile.charging_mode.value), # type: ignore[union-attr]
|
||||
|
|
|
@ -55,7 +55,7 @@ SENSOR_TYPES: dict[str, BMWSensorEntityDescription] = {
|
|||
# --- Generic ---
|
||||
"ac_current_limit": BMWSensorEntityDescription(
|
||||
key="ac_current_limit",
|
||||
name="AC current limit",
|
||||
translation_key="ac_current_limit",
|
||||
key_class="charging_profile",
|
||||
unit_type=UnitOfElectricCurrent.AMPERE,
|
||||
icon="mdi:current-ac",
|
||||
|
@ -63,34 +63,34 @@ SENSOR_TYPES: dict[str, BMWSensorEntityDescription] = {
|
|||
),
|
||||
"charging_start_time": BMWSensorEntityDescription(
|
||||
key="charging_start_time",
|
||||
name="Charging start time",
|
||||
translation_key="charging_start_time",
|
||||
key_class="fuel_and_battery",
|
||||
device_class=SensorDeviceClass.TIMESTAMP,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
"charging_end_time": BMWSensorEntityDescription(
|
||||
key="charging_end_time",
|
||||
name="Charging end time",
|
||||
translation_key="charging_end_time",
|
||||
key_class="fuel_and_battery",
|
||||
device_class=SensorDeviceClass.TIMESTAMP,
|
||||
),
|
||||
"charging_status": BMWSensorEntityDescription(
|
||||
key="charging_status",
|
||||
name="Charging status",
|
||||
translation_key="charging_status",
|
||||
key_class="fuel_and_battery",
|
||||
icon="mdi:ev-station",
|
||||
value=lambda x, y: x.value,
|
||||
),
|
||||
"charging_target": BMWSensorEntityDescription(
|
||||
key="charging_target",
|
||||
name="Charging target",
|
||||
translation_key="charging_target",
|
||||
key_class="fuel_and_battery",
|
||||
icon="mdi:battery-charging-high",
|
||||
unit_type=PERCENTAGE,
|
||||
),
|
||||
"remaining_battery_percent": BMWSensorEntityDescription(
|
||||
key="remaining_battery_percent",
|
||||
name="Remaining battery percent",
|
||||
translation_key="remaining_battery_percent",
|
||||
key_class="fuel_and_battery",
|
||||
unit_type=PERCENTAGE,
|
||||
device_class=SensorDeviceClass.BATTERY,
|
||||
|
@ -98,14 +98,14 @@ SENSOR_TYPES: dict[str, BMWSensorEntityDescription] = {
|
|||
# --- Specific ---
|
||||
"mileage": BMWSensorEntityDescription(
|
||||
key="mileage",
|
||||
name="Mileage",
|
||||
translation_key="mileage",
|
||||
icon="mdi:speedometer",
|
||||
unit_type=LENGTH,
|
||||
value=lambda x, hass: convert_and_round(x, hass.config.units.length, 2),
|
||||
),
|
||||
"remaining_range_total": BMWSensorEntityDescription(
|
||||
key="remaining_range_total",
|
||||
name="Remaining range total",
|
||||
translation_key="remaining_range_total",
|
||||
key_class="fuel_and_battery",
|
||||
icon="mdi:map-marker-distance",
|
||||
unit_type=LENGTH,
|
||||
|
@ -113,7 +113,7 @@ SENSOR_TYPES: dict[str, BMWSensorEntityDescription] = {
|
|||
),
|
||||
"remaining_range_electric": BMWSensorEntityDescription(
|
||||
key="remaining_range_electric",
|
||||
name="Remaining range electric",
|
||||
translation_key="remaining_range_electric",
|
||||
key_class="fuel_and_battery",
|
||||
icon="mdi:map-marker-distance",
|
||||
unit_type=LENGTH,
|
||||
|
@ -121,7 +121,7 @@ SENSOR_TYPES: dict[str, BMWSensorEntityDescription] = {
|
|||
),
|
||||
"remaining_range_fuel": BMWSensorEntityDescription(
|
||||
key="remaining_range_fuel",
|
||||
name="Remaining range fuel",
|
||||
translation_key="remaining_range_fuel",
|
||||
key_class="fuel_and_battery",
|
||||
icon="mdi:map-marker-distance",
|
||||
unit_type=LENGTH,
|
||||
|
@ -129,7 +129,7 @@ SENSOR_TYPES: dict[str, BMWSensorEntityDescription] = {
|
|||
),
|
||||
"remaining_fuel": BMWSensorEntityDescription(
|
||||
key="remaining_fuel",
|
||||
name="Remaining fuel",
|
||||
translation_key="remaining_fuel",
|
||||
key_class="fuel_and_battery",
|
||||
icon="mdi:gas-station",
|
||||
unit_type=VOLUME,
|
||||
|
@ -137,7 +137,7 @@ SENSOR_TYPES: dict[str, BMWSensorEntityDescription] = {
|
|||
),
|
||||
"remaining_fuel_percent": BMWSensorEntityDescription(
|
||||
key="remaining_fuel_percent",
|
||||
name="Remaining fuel percent",
|
||||
translation_key="remaining_fuel_percent",
|
||||
key_class="fuel_and_battery",
|
||||
icon="mdi:gas-station",
|
||||
unit_type=PERCENTAGE,
|
||||
|
|
|
@ -26,5 +26,114 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"binary_sensor": {
|
||||
"lids": {
|
||||
"name": "Lids"
|
||||
},
|
||||
"windows": {
|
||||
"name": "Windows"
|
||||
},
|
||||
"door_lock_state": {
|
||||
"name": "Door lock state"
|
||||
},
|
||||
"condition_based_services": {
|
||||
"name": "Condition based services"
|
||||
},
|
||||
"check_control_messages": {
|
||||
"name": "Check control messages"
|
||||
},
|
||||
"charging_status": {
|
||||
"name": "Charging status"
|
||||
},
|
||||
"connection_status": {
|
||||
"name": "Connection status"
|
||||
},
|
||||
"is_pre_entry_climatization_enabled": {
|
||||
"name": "Pre entry climatization"
|
||||
}
|
||||
},
|
||||
"button": {
|
||||
"light_flash": {
|
||||
"name": "Flash lights"
|
||||
},
|
||||
"sound_horn": {
|
||||
"name": "Sound horn"
|
||||
},
|
||||
"activate_air_conditioning": {
|
||||
"name": "Activate air conditioning"
|
||||
},
|
||||
"find_vehicle": {
|
||||
"name": "Find vehicle"
|
||||
},
|
||||
"refresh": {
|
||||
"name": "Refresh from cloud"
|
||||
}
|
||||
},
|
||||
"lock": {
|
||||
"lock": {
|
||||
"name": "[%key:component::lock::title%]"
|
||||
}
|
||||
},
|
||||
"number": {
|
||||
"target_soc": {
|
||||
"name": "Target SoC"
|
||||
}
|
||||
},
|
||||
"select": {
|
||||
"ac_limit": {
|
||||
"name": "AC Charging Limit"
|
||||
},
|
||||
"charging_mode": {
|
||||
"name": "Charging Mode"
|
||||
}
|
||||
},
|
||||
"sensor": {
|
||||
"ac_current_limit": {
|
||||
"name": "AC current limit"
|
||||
},
|
||||
"charging_start_time": {
|
||||
"name": "Charging start time"
|
||||
},
|
||||
"charging_end_time": {
|
||||
"name": "Charging end time"
|
||||
},
|
||||
"charging_status": {
|
||||
"name": "Charging status"
|
||||
},
|
||||
"charging_target": {
|
||||
"name": "Charging target"
|
||||
},
|
||||
"remaining_battery_percent": {
|
||||
"name": "Remaining battery percent"
|
||||
},
|
||||
"mileage": {
|
||||
"name": "Mileage"
|
||||
},
|
||||
"remaining_range_total": {
|
||||
"name": "Remaining range total"
|
||||
},
|
||||
"remaining_range_electric": {
|
||||
"name": "Remaining range electric"
|
||||
},
|
||||
"remaining_range_fuel": {
|
||||
"name": "Remaining range fuel"
|
||||
},
|
||||
"remaining_fuel": {
|
||||
"name": "Remaining fuel"
|
||||
},
|
||||
"remaining_fuel_percent": {
|
||||
"name": "Remaining fuel percent"
|
||||
}
|
||||
},
|
||||
"switch": {
|
||||
"climate": {
|
||||
"name": "Climate"
|
||||
},
|
||||
"charging": {
|
||||
"name": "Charging"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ CHARGING_STATE_ON = {
|
|||
NUMBER_TYPES: list[BMWSwitchEntityDescription] = [
|
||||
BMWSwitchEntityDescription(
|
||||
key="climate",
|
||||
name="Climate",
|
||||
translation_key="climate",
|
||||
is_available=lambda v: v.is_remote_climate_stop_enabled,
|
||||
value_fn=lambda v: v.climate.is_climate_on,
|
||||
remote_service_on=lambda v: v.remote_services.trigger_remote_air_conditioning(),
|
||||
|
@ -60,7 +60,7 @@ NUMBER_TYPES: list[BMWSwitchEntityDescription] = [
|
|||
),
|
||||
BMWSwitchEntityDescription(
|
||||
key="charging",
|
||||
name="Charging",
|
||||
translation_key="charging",
|
||||
is_available=lambda v: v.is_remote_charge_stop_enabled,
|
||||
value_fn=lambda v: v.fuel_and_battery.charging_status in CHARGING_STATE_ON,
|
||||
remote_service_on=lambda v: v.remote_services.trigger_charge_start(),
|
||||
|
|
Loading…
Reference in New Issue