Skip to content

Commit

Permalink
Add icon translations to BMW (#111348)
Browse files Browse the repository at this point in the history
* Add icon translations to BMW

* Add icon translations to BMW
  • Loading branch information
joostlek committed Feb 28, 2024
1 parent 40431a9 commit a8887d5
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 80 deletions.
8 changes: 0 additions & 8 deletions homeassistant/components/bmw_connected_drive/binary_sensor.py
Expand Up @@ -130,7 +130,6 @@ class BMWBinarySensorEntityDescription(
key="lids",
translation_key="lids",
device_class=BinarySensorDeviceClass.OPENING,
icon="mdi:car-door-lock",
# device class opening: On means open, Off means closed
value_fn=lambda v: not v.doors_and_windows.all_lids_closed,
attr_fn=lambda v, u: {
Expand All @@ -141,7 +140,6 @@ class BMWBinarySensorEntityDescription(
key="windows",
translation_key="windows",
device_class=BinarySensorDeviceClass.OPENING,
icon="mdi:car-door",
# device class opening: On means open, Off means closed
value_fn=lambda v: not v.doors_and_windows.all_windows_closed,
attr_fn=lambda v, u: {
Expand All @@ -152,7 +150,6 @@ class BMWBinarySensorEntityDescription(
key="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
# Possible values: LOCKED, SECURED, SELECTIVE_LOCKED, UNLOCKED
value_fn=lambda v: v.doors_and_windows.door_lock_state
Expand All @@ -165,7 +162,6 @@ class BMWBinarySensorEntityDescription(
key="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
value_fn=lambda v: v.condition_based_services.is_service_required,
attr_fn=_condition_based_services,
Expand All @@ -174,7 +170,6 @@ class BMWBinarySensorEntityDescription(
key="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
value_fn=lambda v: v.check_control_messages.has_check_control_messages,
attr_fn=lambda v, u: _check_control_messages(v),
Expand All @@ -184,21 +179,18 @@ class BMWBinarySensorEntityDescription(
key="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
value_fn=lambda v: v.fuel_and_battery.charging_status == ChargingState.CHARGING,
),
BMWBinarySensorEntityDescription(
key="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",
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
else False,
Expand Down
6 changes: 1 addition & 5 deletions homeassistant/components/bmw_connected_drive/button.py
Expand Up @@ -44,32 +44,28 @@ class BMWButtonEntityDescription(ButtonEntityDescription, BMWRequiredKeysMixin):
BMWButtonEntityDescription(
key="light_flash",
translation_key="light_flash",
icon="mdi:car-light-alert",
remote_function=lambda vehicle: vehicle.remote_services.trigger_remote_light_flash(),
),
BMWButtonEntityDescription(
key="sound_horn",
translation_key="sound_horn",
icon="mdi:bullhorn",
remote_function=lambda vehicle: vehicle.remote_services.trigger_remote_horn(),
),
BMWButtonEntityDescription(
key="activate_air_conditioning",
translation_key="activate_air_conditioning",
icon="mdi:hvac",
remote_function=lambda vehicle: vehicle.remote_services.trigger_remote_air_conditioning(),
),
BMWButtonEntityDescription(
key="deactivate_air_conditioning",
icon="mdi:hvac-off",
translation_key="deactivate_air_conditioning",
name="Deactivate air conditioning",
remote_function=lambda vehicle: vehicle.remote_services.trigger_remote_air_conditioning_stop(),
is_available=lambda vehicle: vehicle.is_remote_climate_stop_enabled,
),
BMWButtonEntityDescription(
key="find_vehicle",
translation_key="find_vehicle",
icon="mdi:crosshairs-question",
remote_function=lambda vehicle: vehicle.remote_services.trigger_remote_vehicle_finder(),
),
)
Expand Down
Expand Up @@ -45,6 +45,7 @@ class BMWDeviceTracker(BMWBaseEntity, TrackerEntity):
"""MyBMW device tracker."""

_attr_force_update = False
_attr_translation_key = "car"
_attr_icon = "mdi:car"

def __init__(
Expand Down
99 changes: 99 additions & 0 deletions homeassistant/components/bmw_connected_drive/icons.json
@@ -0,0 +1,99 @@
{
"entity": {
"binary_sensor": {
"lids": {
"default": "mdi:car-door-lock"
},
"windows": {
"default": "mdi:car-door"
},
"door_lock_state": {
"default": "mdi:car-key"
},
"condition_based_services": {
"default": "mdi:wrench"
},
"check_control_messages": {
"default": "mdi:car-tire-alert"
},
"charging_status": {
"default": "mdi:ev-station"
},
"connection_status": {
"default": "mdi:car-electric"
},
"is_pre_entry_climatization_enabled": {
"default": "mdi:car-seat-heater"
}
},
"button": {
"light_flash": {
"default": "mdi:car-light-alert"
},
"sound_horn": {
"default": "mdi:bullhorn"
},
"activate_air_conditioning": {
"default": "mdi:hvac"
},
"deactivate_air_conditioning": {
"default": "mdi:hvac-off"
},
"find_vehicle": {
"default": "mdi:crosshairs-question"
}
},
"device_tracker": {
"car": {
"default": "mdi:car"
}
},
"number": {
"target_soc": {
"default": "mdi:battery-charging-medium"
}
},
"select": {
"ac_limit": {
"default": "mdi:current-ac"
},
"charging_mode": {
"default": "mdi:vector-point-select"
}
},
"sensor": {
"charging_status": {
"default": "mdi:ev-station"
},
"charging_target": {
"default": "mdi:battery-charging-high"
},
"mileage": {
"default": "mdi:speedometer"
},
"remaining_range_total": {
"default": "mdi:map-marker-distance"
},
"remaining_range_electric": {
"default": "mdi:map-marker-distance"
},
"remaining_range_fuel": {
"default": "mdi:map-marker-distance"
},
"remaining_fuel": {
"default": "mdi:gas-station"
},
"remaining_fuel_percent": {
"default": "mdi:gas-station"
}
},
"switch": {
"climate": {
"default": "mdi:fan"
},
"charging": {
"default": "mdi:ev-station"
}
}
}
}
1 change: 0 additions & 1 deletion homeassistant/components/bmw_connected_drive/number.py
Expand Up @@ -56,7 +56,6 @@ class BMWNumberEntityDescription(NumberEntityDescription, BMWRequiredKeysMixin):
remote_service=lambda v, o: v.remote_services.trigger_charging_settings_update(
target_soc=int(o)
),
icon="mdi:battery-charging-medium",
),
]

Expand Down
2 changes: 0 additions & 2 deletions homeassistant/components/bmw_connected_drive/select.py
Expand Up @@ -51,7 +51,6 @@ class BMWSelectEntityDescription(SelectEntityDescription, BMWRequiredKeysMixin):
remote_service=lambda v, o: v.remote_services.trigger_charging_settings_update(
ac_limit=int(o)
),
icon="mdi:current-ac",
unit_of_measurement=UnitOfElectricCurrent.AMPERE,
),
"charging_mode": BMWSelectEntityDescription(
Expand All @@ -63,7 +62,6 @@ class BMWSelectEntityDescription(SelectEntityDescription, BMWRequiredKeysMixin):
remote_service=lambda v, o: v.remote_services.trigger_charging_profile_update(
charging_mode=ChargingMode(o)
),
icon="mdi:vector-point-select",
),
}

Expand Down
9 changes: 0 additions & 9 deletions homeassistant/components/bmw_connected_drive/sensor.py
Expand Up @@ -59,7 +59,6 @@ def convert_and_round(
translation_key="ac_current_limit",
key_class="charging_profile",
unit_type=UnitOfElectricCurrent.AMPERE,
icon="mdi:current-ac",
entity_registry_enabled_default=False,
),
"charging_start_time": BMWSensorEntityDescription(
Expand All @@ -79,14 +78,12 @@ def convert_and_round(
key="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",
translation_key="charging_target",
key_class="fuel_and_battery",
icon="mdi:battery-charging-high",
unit_type=PERCENTAGE,
),
"remaining_battery_percent": BMWSensorEntityDescription(
Expand All @@ -101,7 +98,6 @@ def convert_and_round(
"mileage": BMWSensorEntityDescription(
key="mileage",
translation_key="mileage",
icon="mdi:speedometer",
unit_type=LENGTH,
value=lambda x, hass: convert_and_round(x, hass.config.units.length, 2),
state_class=SensorStateClass.TOTAL_INCREASING,
Expand All @@ -110,7 +106,6 @@ def convert_and_round(
key="remaining_range_total",
translation_key="remaining_range_total",
key_class="fuel_and_battery",
icon="mdi:map-marker-distance",
unit_type=LENGTH,
value=lambda x, hass: convert_and_round(x, hass.config.units.length, 2),
state_class=SensorStateClass.MEASUREMENT,
Expand All @@ -119,7 +114,6 @@ def convert_and_round(
key="remaining_range_electric",
translation_key="remaining_range_electric",
key_class="fuel_and_battery",
icon="mdi:map-marker-distance",
unit_type=LENGTH,
value=lambda x, hass: convert_and_round(x, hass.config.units.length, 2),
state_class=SensorStateClass.MEASUREMENT,
Expand All @@ -128,7 +122,6 @@ def convert_and_round(
key="remaining_range_fuel",
translation_key="remaining_range_fuel",
key_class="fuel_and_battery",
icon="mdi:map-marker-distance",
unit_type=LENGTH,
value=lambda x, hass: convert_and_round(x, hass.config.units.length, 2),
state_class=SensorStateClass.MEASUREMENT,
Expand All @@ -137,7 +130,6 @@ def convert_and_round(
key="remaining_fuel",
translation_key="remaining_fuel",
key_class="fuel_and_battery",
icon="mdi:gas-station",
unit_type=VOLUME,
value=lambda x, hass: convert_and_round(x, hass.config.units.volume, 2),
state_class=SensorStateClass.MEASUREMENT,
Expand All @@ -146,7 +138,6 @@ def convert_and_round(
key="remaining_fuel_percent",
translation_key="remaining_fuel_percent",
key_class="fuel_and_battery",
icon="mdi:gas-station",
unit_type=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
),
Expand Down
2 changes: 0 additions & 2 deletions homeassistant/components/bmw_connected_drive/switch.py
Expand Up @@ -56,7 +56,6 @@ class BMWSwitchEntityDescription(SwitchEntityDescription, BMWRequiredKeysMixin):
value_fn=lambda v: v.climate.is_climate_on,
remote_service_on=lambda v: v.remote_services.trigger_remote_air_conditioning(),
remote_service_off=lambda v: v.remote_services.trigger_remote_air_conditioning_stop(),
icon="mdi:fan",
),
BMWSwitchEntityDescription(
key="charging",
Expand All @@ -65,7 +64,6 @@ class BMWSwitchEntityDescription(SwitchEntityDescription, BMWRequiredKeysMixin):
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(),
remote_service_off=lambda v: v.remote_services.trigger_charge_stop(),
icon="mdi:ev-station",
),
]

Expand Down

0 comments on commit a8887d5

Please sign in to comment.