Change BMW select and sensor enums to lowercase (#118751)
Co-authored-by: Richard <rikroe@users.noreply.github.com>
This commit is contained in:
parent
cb672b85f4
commit
b04a65f4d1
6 changed files with 45 additions and 31 deletions
|
@ -52,8 +52,8 @@ SELECT_TYPES: dict[str, BMWSelectEntityDescription] = {
|
|||
key="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]
|
||||
options=[c.value.lower() for c in ChargingMode if c != ChargingMode.UNKNOWN],
|
||||
current_option=lambda v: str(v.charging_profile.charging_mode.value).lower(), # type: ignore[union-attr]
|
||||
remote_service=lambda v, o: v.remote_services.trigger_charging_profile_update(
|
||||
charging_mode=ChargingMode(o)
|
||||
),
|
||||
|
|
|
@ -221,9 +221,5 @@ class BMWSensor(BMWBaseEntity, SensorEntity):
|
|||
if state == STATE_UNKNOWN:
|
||||
state = None
|
||||
|
||||
# special handling for charging_status to avoid a breaking change
|
||||
if self.entity_description.key == "charging_status" and state:
|
||||
state = state.upper()
|
||||
|
||||
self._attr_native_value = state
|
||||
super()._handle_coordinator_update()
|
||||
|
|
|
@ -83,7 +83,11 @@
|
|||
"name": "AC Charging Limit"
|
||||
},
|
||||
"charging_mode": {
|
||||
"name": "Charging Mode"
|
||||
"name": "Charging Mode",
|
||||
"state": {
|
||||
"immediate_charging": "Immediate charging",
|
||||
"delayed_charging": "Delayed charging"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sensor": {
|
||||
|
@ -97,7 +101,21 @@
|
|||
"name": "Charging end time"
|
||||
},
|
||||
"charging_status": {
|
||||
"name": "Charging status"
|
||||
"name": "Charging status",
|
||||
"state": {
|
||||
"default": "Default",
|
||||
"charging": "Charging",
|
||||
"error": "Error",
|
||||
"complete": "Complete",
|
||||
"fully_charged": "Fully charged",
|
||||
"finished_fully_charged": "Finished, fully charged",
|
||||
"finished_not_full": "Finished, not full",
|
||||
"invalid": "Invalid",
|
||||
"not_charging": "Not charging",
|
||||
"plugged_in": "Plugged in",
|
||||
"waiting_for_charging": "Waiting for charging",
|
||||
"target_reached": "Target reached"
|
||||
}
|
||||
},
|
||||
"charging_target": {
|
||||
"name": "Charging target"
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'options': list([
|
||||
'IMMEDIATE_CHARGING',
|
||||
'DELAYED_CHARGING',
|
||||
'immediate_charging',
|
||||
'delayed_charging',
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
|
@ -43,8 +43,8 @@
|
|||
'attribution': 'Data provided by MyBMW',
|
||||
'friendly_name': 'i3 (+ REX) Charging Mode',
|
||||
'options': list([
|
||||
'IMMEDIATE_CHARGING',
|
||||
'DELAYED_CHARGING',
|
||||
'immediate_charging',
|
||||
'delayed_charging',
|
||||
]),
|
||||
}),
|
||||
'context': <ANY>,
|
||||
|
@ -52,7 +52,7 @@
|
|||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'DELAYED_CHARGING',
|
||||
'state': 'delayed_charging',
|
||||
})
|
||||
# ---
|
||||
# name: test_entity_state_attrs[select.i4_edrive40_ac_charging_limit-entry]
|
||||
|
@ -141,8 +141,8 @@
|
|||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'options': list([
|
||||
'IMMEDIATE_CHARGING',
|
||||
'DELAYED_CHARGING',
|
||||
'immediate_charging',
|
||||
'delayed_charging',
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
|
@ -178,8 +178,8 @@
|
|||
'attribution': 'Data provided by MyBMW',
|
||||
'friendly_name': 'i4 eDrive40 Charging Mode',
|
||||
'options': list([
|
||||
'IMMEDIATE_CHARGING',
|
||||
'DELAYED_CHARGING',
|
||||
'immediate_charging',
|
||||
'delayed_charging',
|
||||
]),
|
||||
}),
|
||||
'context': <ANY>,
|
||||
|
@ -187,7 +187,7 @@
|
|||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'IMMEDIATE_CHARGING',
|
||||
'state': 'immediate_charging',
|
||||
})
|
||||
# ---
|
||||
# name: test_entity_state_attrs[select.ix_xdrive50_ac_charging_limit-entry]
|
||||
|
@ -276,8 +276,8 @@
|
|||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'options': list([
|
||||
'IMMEDIATE_CHARGING',
|
||||
'DELAYED_CHARGING',
|
||||
'immediate_charging',
|
||||
'delayed_charging',
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
|
@ -313,8 +313,8 @@
|
|||
'attribution': 'Data provided by MyBMW',
|
||||
'friendly_name': 'iX xDrive50 Charging Mode',
|
||||
'options': list([
|
||||
'IMMEDIATE_CHARGING',
|
||||
'DELAYED_CHARGING',
|
||||
'immediate_charging',
|
||||
'delayed_charging',
|
||||
]),
|
||||
}),
|
||||
'context': <ANY>,
|
||||
|
@ -322,6 +322,6 @@
|
|||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'IMMEDIATE_CHARGING',
|
||||
'state': 'immediate_charging',
|
||||
})
|
||||
# ---
|
||||
|
|
|
@ -191,7 +191,7 @@
|
|||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'WAITING_FOR_CHARGING',
|
||||
'state': 'waiting_for_charging',
|
||||
})
|
||||
# ---
|
||||
# name: test_entity_state_attrs[sensor.i3_rex_charging_target-entry]
|
||||
|
@ -822,7 +822,7 @@
|
|||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'NOT_CHARGING',
|
||||
'state': 'not_charging',
|
||||
})
|
||||
# ---
|
||||
# name: test_entity_state_attrs[sensor.i4_edrive40_charging_target-entry]
|
||||
|
@ -1350,7 +1350,7 @@
|
|||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'CHARGING',
|
||||
'state': 'charging',
|
||||
})
|
||||
# ---
|
||||
# name: test_entity_state_attrs[sensor.ix_xdrive50_charging_target-entry]
|
||||
|
|
|
@ -42,15 +42,15 @@ async def test_entity_state_attrs(
|
|||
[
|
||||
(
|
||||
"select.i3_rex_charging_mode",
|
||||
"IMMEDIATE_CHARGING",
|
||||
"DELAYED_CHARGING",
|
||||
"immediate_charging",
|
||||
"delayed_charging",
|
||||
"charging-profile",
|
||||
),
|
||||
("select.i4_edrive40_ac_charging_limit", "12", "16", "charging-settings"),
|
||||
(
|
||||
"select.i4_edrive40_charging_mode",
|
||||
"DELAYED_CHARGING",
|
||||
"IMMEDIATE_CHARGING",
|
||||
"delayed_charging",
|
||||
"immediate_charging",
|
||||
"charging-profile",
|
||||
),
|
||||
],
|
||||
|
@ -87,7 +87,7 @@ async def test_service_call_success(
|
|||
("entity_id", "value"),
|
||||
[
|
||||
("select.i4_edrive40_ac_charging_limit", "17"),
|
||||
("select.i4_edrive40_charging_mode", "BONKERS_MODE"),
|
||||
("select.i4_edrive40_charging_mode", "bonkers_mode"),
|
||||
],
|
||||
)
|
||||
async def test_service_call_invalid_input(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue