mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +00:00
Fix renault plug state (#125421)
* Added PlugState 3, that is coming with renault-api 0.2.7, it fixes #124682 HA ticket * Added PlugState 3, that is coming with renault-api 0.2.7, it fixes #124682 HA ticket
This commit is contained in:
parent
17994ff245
commit
3e70342265
@ -28,7 +28,7 @@ class RenaultBinarySensorEntityDescription(
|
|||||||
"""Class describing Renault binary sensor entities."""
|
"""Class describing Renault binary sensor entities."""
|
||||||
|
|
||||||
on_key: str
|
on_key: str
|
||||||
on_value: StateType
|
on_value: StateType | list[StateType]
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@ -58,6 +58,9 @@ class RenaultBinarySensor(
|
|||||||
"""Return true if the binary sensor is on."""
|
"""Return true if the binary sensor is on."""
|
||||||
if (data := self._get_data_attr(self.entity_description.on_key)) is None:
|
if (data := self._get_data_attr(self.entity_description.on_key)) is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
if isinstance(self.entity_description.on_value, list):
|
||||||
|
return data in self.entity_description.on_value
|
||||||
return data == self.entity_description.on_value
|
return data == self.entity_description.on_value
|
||||||
|
|
||||||
|
|
||||||
@ -68,7 +71,10 @@ BINARY_SENSOR_TYPES: tuple[RenaultBinarySensorEntityDescription, ...] = tuple(
|
|||||||
coordinator="battery",
|
coordinator="battery",
|
||||||
device_class=BinarySensorDeviceClass.PLUG,
|
device_class=BinarySensorDeviceClass.PLUG,
|
||||||
on_key="plugStatus",
|
on_key="plugStatus",
|
||||||
on_value=PlugState.PLUGGED.value,
|
on_value=[
|
||||||
|
PlugState.PLUGGED.value,
|
||||||
|
PlugState.PLUGGED_WAITING_FOR_CHARGE.value,
|
||||||
|
],
|
||||||
),
|
),
|
||||||
RenaultBinarySensorEntityDescription(
|
RenaultBinarySensorEntityDescription(
|
||||||
key="charging",
|
key="charging",
|
||||||
@ -104,13 +110,13 @@ BINARY_SENSOR_TYPES: tuple[RenaultBinarySensorEntityDescription, ...] = tuple(
|
|||||||
]
|
]
|
||||||
+ [
|
+ [
|
||||||
RenaultBinarySensorEntityDescription(
|
RenaultBinarySensorEntityDescription(
|
||||||
key=f"{door.replace(' ','_').lower()}_door_status",
|
key=f"{door.replace(' ', '_').lower()}_door_status",
|
||||||
coordinator="lock_status",
|
coordinator="lock_status",
|
||||||
# On means open, Off means closed
|
# On means open, Off means closed
|
||||||
device_class=BinarySensorDeviceClass.DOOR,
|
device_class=BinarySensorDeviceClass.DOOR,
|
||||||
on_key=f"doorStatus{door.replace(' ','')}",
|
on_key=f"doorStatus{door.replace(' ', '')}",
|
||||||
on_value="open",
|
on_value="open",
|
||||||
translation_key=f"{door.lower().replace(' ','_')}_door_status",
|
translation_key=f"{door.lower().replace(' ', '_')}_door_status",
|
||||||
)
|
)
|
||||||
for door in ("Rear Left", "Rear Right", "Driver", "Passenger")
|
for door in ("Rear Left", "Rear Right", "Driver", "Passenger")
|
||||||
],
|
],
|
||||||
|
@ -197,7 +197,13 @@ SENSOR_TYPES: tuple[RenaultSensorEntityDescription[Any], ...] = (
|
|||||||
translation_key="plug_state",
|
translation_key="plug_state",
|
||||||
device_class=SensorDeviceClass.ENUM,
|
device_class=SensorDeviceClass.ENUM,
|
||||||
entity_class=RenaultSensor[KamereonVehicleBatteryStatusData],
|
entity_class=RenaultSensor[KamereonVehicleBatteryStatusData],
|
||||||
options=["unplugged", "plugged", "plug_error", "plug_unknown"],
|
options=[
|
||||||
|
"unplugged",
|
||||||
|
"plugged",
|
||||||
|
"plugged_waiting_for_charge",
|
||||||
|
"plug_error",
|
||||||
|
"plug_unknown",
|
||||||
|
],
|
||||||
value_lambda=_get_plug_state_formatted,
|
value_lambda=_get_plug_state_formatted,
|
||||||
),
|
),
|
||||||
RenaultSensorEntityDescription(
|
RenaultSensorEntityDescription(
|
||||||
|
@ -141,6 +141,7 @@
|
|||||||
"state": {
|
"state": {
|
||||||
"unplugged": "Unplugged",
|
"unplugged": "Unplugged",
|
||||||
"plugged": "Plugged in",
|
"plugged": "Plugged in",
|
||||||
|
"plugged_waiting_for_charge": "Plugged in, waiting for charge",
|
||||||
"plug_error": "Plug error",
|
"plug_error": "Plug error",
|
||||||
"plug_unknown": "Plug unknown"
|
"plug_unknown": "Plug unknown"
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,13 @@ MOCK_VEHICLES = {
|
|||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.ENUM,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.ENUM,
|
||||||
ATTR_ENTITY_ID: "sensor.reg_number_plug_state",
|
ATTR_ENTITY_ID: "sensor.reg_number_plug_state",
|
||||||
ATTR_ICON: "mdi:power-plug",
|
ATTR_ICON: "mdi:power-plug",
|
||||||
ATTR_OPTIONS: ["unplugged", "plugged", "plug_error", "plug_unknown"],
|
ATTR_OPTIONS: [
|
||||||
|
"unplugged",
|
||||||
|
"plugged",
|
||||||
|
"plugged_waiting_for_charge",
|
||||||
|
"plug_error",
|
||||||
|
"plug_unknown",
|
||||||
|
],
|
||||||
ATTR_STATE: "plugged",
|
ATTR_STATE: "plugged",
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_plug_state",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777999_plug_state",
|
||||||
},
|
},
|
||||||
@ -487,7 +493,13 @@ MOCK_VEHICLES = {
|
|||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.ENUM,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.ENUM,
|
||||||
ATTR_ENTITY_ID: "sensor.reg_number_plug_state",
|
ATTR_ENTITY_ID: "sensor.reg_number_plug_state",
|
||||||
ATTR_ICON: "mdi:power-plug-off",
|
ATTR_ICON: "mdi:power-plug-off",
|
||||||
ATTR_OPTIONS: ["unplugged", "plugged", "plug_error", "plug_unknown"],
|
ATTR_OPTIONS: [
|
||||||
|
"unplugged",
|
||||||
|
"plugged",
|
||||||
|
"plugged_waiting_for_charge",
|
||||||
|
"plug_error",
|
||||||
|
"plug_unknown",
|
||||||
|
],
|
||||||
ATTR_STATE: "unplugged",
|
ATTR_STATE: "unplugged",
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_plug_state",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777999_plug_state",
|
||||||
},
|
},
|
||||||
@ -725,7 +737,13 @@ MOCK_VEHICLES = {
|
|||||||
ATTR_DEVICE_CLASS: SensorDeviceClass.ENUM,
|
ATTR_DEVICE_CLASS: SensorDeviceClass.ENUM,
|
||||||
ATTR_ENTITY_ID: "sensor.reg_number_plug_state",
|
ATTR_ENTITY_ID: "sensor.reg_number_plug_state",
|
||||||
ATTR_ICON: "mdi:power-plug",
|
ATTR_ICON: "mdi:power-plug",
|
||||||
ATTR_OPTIONS: ["unplugged", "plugged", "plug_error", "plug_unknown"],
|
ATTR_OPTIONS: [
|
||||||
|
"unplugged",
|
||||||
|
"plugged",
|
||||||
|
"plugged_waiting_for_charge",
|
||||||
|
"plug_error",
|
||||||
|
"plug_unknown",
|
||||||
|
],
|
||||||
ATTR_STATE: "plugged",
|
ATTR_STATE: "plugged",
|
||||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_plug_state",
|
ATTR_UNIQUE_ID: "vf1aaaaa555777123_plug_state",
|
||||||
},
|
},
|
||||||
|
@ -494,6 +494,7 @@
|
|||||||
'options': list([
|
'options': list([
|
||||||
'unplugged',
|
'unplugged',
|
||||||
'plugged',
|
'plugged',
|
||||||
|
'plugged_waiting_for_charge',
|
||||||
'plug_error',
|
'plug_error',
|
||||||
'plug_unknown',
|
'plug_unknown',
|
||||||
]),
|
]),
|
||||||
@ -921,6 +922,7 @@
|
|||||||
'options': list([
|
'options': list([
|
||||||
'unplugged',
|
'unplugged',
|
||||||
'plugged',
|
'plugged',
|
||||||
|
'plugged_waiting_for_charge',
|
||||||
'plug_error',
|
'plug_error',
|
||||||
'plug_unknown',
|
'plug_unknown',
|
||||||
]),
|
]),
|
||||||
@ -1249,6 +1251,7 @@
|
|||||||
'options': list([
|
'options': list([
|
||||||
'unplugged',
|
'unplugged',
|
||||||
'plugged',
|
'plugged',
|
||||||
|
'plugged_waiting_for_charge',
|
||||||
'plug_error',
|
'plug_error',
|
||||||
'plug_unknown',
|
'plug_unknown',
|
||||||
]),
|
]),
|
||||||
@ -1674,6 +1677,7 @@
|
|||||||
'options': list([
|
'options': list([
|
||||||
'unplugged',
|
'unplugged',
|
||||||
'plugged',
|
'plugged',
|
||||||
|
'plugged_waiting_for_charge',
|
||||||
'plug_error',
|
'plug_error',
|
||||||
'plug_unknown',
|
'plug_unknown',
|
||||||
]),
|
]),
|
||||||
@ -2000,6 +2004,7 @@
|
|||||||
'options': list([
|
'options': list([
|
||||||
'unplugged',
|
'unplugged',
|
||||||
'plugged',
|
'plugged',
|
||||||
|
'plugged_waiting_for_charge',
|
||||||
'plug_error',
|
'plug_error',
|
||||||
'plug_unknown',
|
'plug_unknown',
|
||||||
]),
|
]),
|
||||||
@ -2456,6 +2461,7 @@
|
|||||||
'options': list([
|
'options': list([
|
||||||
'unplugged',
|
'unplugged',
|
||||||
'plugged',
|
'plugged',
|
||||||
|
'plugged_waiting_for_charge',
|
||||||
'plug_error',
|
'plug_error',
|
||||||
'plug_unknown',
|
'plug_unknown',
|
||||||
]),
|
]),
|
||||||
@ -3104,6 +3110,7 @@
|
|||||||
'options': list([
|
'options': list([
|
||||||
'unplugged',
|
'unplugged',
|
||||||
'plugged',
|
'plugged',
|
||||||
|
'plugged_waiting_for_charge',
|
||||||
'plug_error',
|
'plug_error',
|
||||||
'plug_unknown',
|
'plug_unknown',
|
||||||
]),
|
]),
|
||||||
@ -3531,6 +3538,7 @@
|
|||||||
'options': list([
|
'options': list([
|
||||||
'unplugged',
|
'unplugged',
|
||||||
'plugged',
|
'plugged',
|
||||||
|
'plugged_waiting_for_charge',
|
||||||
'plug_error',
|
'plug_error',
|
||||||
'plug_unknown',
|
'plug_unknown',
|
||||||
]),
|
]),
|
||||||
@ -3859,6 +3867,7 @@
|
|||||||
'options': list([
|
'options': list([
|
||||||
'unplugged',
|
'unplugged',
|
||||||
'plugged',
|
'plugged',
|
||||||
|
'plugged_waiting_for_charge',
|
||||||
'plug_error',
|
'plug_error',
|
||||||
'plug_unknown',
|
'plug_unknown',
|
||||||
]),
|
]),
|
||||||
@ -4284,6 +4293,7 @@
|
|||||||
'options': list([
|
'options': list([
|
||||||
'unplugged',
|
'unplugged',
|
||||||
'plugged',
|
'plugged',
|
||||||
|
'plugged_waiting_for_charge',
|
||||||
'plug_error',
|
'plug_error',
|
||||||
'plug_unknown',
|
'plug_unknown',
|
||||||
]),
|
]),
|
||||||
@ -4610,6 +4620,7 @@
|
|||||||
'options': list([
|
'options': list([
|
||||||
'unplugged',
|
'unplugged',
|
||||||
'plugged',
|
'plugged',
|
||||||
|
'plugged_waiting_for_charge',
|
||||||
'plug_error',
|
'plug_error',
|
||||||
'plug_unknown',
|
'plug_unknown',
|
||||||
]),
|
]),
|
||||||
@ -5066,6 +5077,7 @@
|
|||||||
'options': list([
|
'options': list([
|
||||||
'unplugged',
|
'unplugged',
|
||||||
'plugged',
|
'plugged',
|
||||||
|
'plugged_waiting_for_charge',
|
||||||
'plug_error',
|
'plug_error',
|
||||||
'plug_unknown',
|
'plug_unknown',
|
||||||
]),
|
]),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user