Replace slave by meter in v2c (#118893)
This commit is contained in:
parent
e2dd88be6e
commit
0562c3085f
5 changed files with 20 additions and 15 deletions
homeassistant/components/v2c
tests/components/v2c
|
@ -16,7 +16,7 @@
|
|||
"fv_power": {
|
||||
"default": "mdi:solar-power-variant"
|
||||
},
|
||||
"slave_error": {
|
||||
"meter_error": {
|
||||
"default": "mdi:alert"
|
||||
},
|
||||
"battery_power": {
|
||||
|
|
|
@ -35,7 +35,12 @@ class V2CSensorEntityDescription(SensorEntityDescription):
|
|||
value_fn: Callable[[TrydanData], StateType]
|
||||
|
||||
|
||||
_METER_ERROR_OPTIONS = [error.name.lower() for error in SlaveCommunicationState]
|
||||
def get_meter_value(value: SlaveCommunicationState) -> str:
|
||||
"""Return the value of the enum and replace slave by meter."""
|
||||
return value.name.lower().replace("slave", "meter")
|
||||
|
||||
|
||||
_METER_ERROR_OPTIONS = [get_meter_value(error) for error in SlaveCommunicationState]
|
||||
|
||||
TRYDAN_SENSORS = (
|
||||
V2CSensorEntityDescription(
|
||||
|
@ -82,7 +87,7 @@ TRYDAN_SENSORS = (
|
|||
V2CSensorEntityDescription(
|
||||
key="meter_error",
|
||||
translation_key="meter_error",
|
||||
value_fn=lambda evse_data: evse_data.slave_error.name.lower(),
|
||||
value_fn=lambda evse_data: get_meter_value(evse_data.slave_error),
|
||||
entity_registry_enabled_default=False,
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
options=_METER_ERROR_OPTIONS,
|
||||
|
|
|
@ -60,12 +60,12 @@
|
|||
"no_error": "No error",
|
||||
"communication": "Communication",
|
||||
"reading": "Reading",
|
||||
"slave": "Meter",
|
||||
"meter": "Meter",
|
||||
"waiting_wifi": "Waiting for Wi-Fi",
|
||||
"waiting_communication": "Waiting communication",
|
||||
"wrong_ip": "Wrong IP",
|
||||
"slave_not_found": "Meter not found",
|
||||
"wrong_slave": "Wrong Meter",
|
||||
"meter_not_found": "Meter not found",
|
||||
"wrong_meter": "Wrong meter",
|
||||
"no_response": "No response",
|
||||
"clamp_not_connected": "Clamp not connected",
|
||||
"illegal_function": "Illegal function",
|
||||
|
|
|
@ -265,12 +265,12 @@
|
|||
'no_error',
|
||||
'communication',
|
||||
'reading',
|
||||
'slave',
|
||||
'meter',
|
||||
'waiting_wifi',
|
||||
'waiting_communication',
|
||||
'wrong_ip',
|
||||
'slave_not_found',
|
||||
'wrong_slave',
|
||||
'meter_not_found',
|
||||
'wrong_meter',
|
||||
'no_response',
|
||||
'clamp_not_connected',
|
||||
'illegal_function',
|
||||
|
@ -335,12 +335,12 @@
|
|||
'no_error',
|
||||
'communication',
|
||||
'reading',
|
||||
'slave',
|
||||
'meter',
|
||||
'waiting_wifi',
|
||||
'waiting_communication',
|
||||
'wrong_ip',
|
||||
'slave_not_found',
|
||||
'wrong_slave',
|
||||
'meter_not_found',
|
||||
'wrong_meter',
|
||||
'no_response',
|
||||
'clamp_not_connected',
|
||||
'illegal_function',
|
||||
|
|
|
@ -33,12 +33,12 @@ async def test_sensor(
|
|||
"no_error",
|
||||
"communication",
|
||||
"reading",
|
||||
"slave",
|
||||
"meter",
|
||||
"waiting_wifi",
|
||||
"waiting_communication",
|
||||
"wrong_ip",
|
||||
"slave_not_found",
|
||||
"wrong_slave",
|
||||
"meter_not_found",
|
||||
"wrong_meter",
|
||||
"no_response",
|
||||
"clamp_not_connected",
|
||||
"illegal_function",
|
||||
|
|
Loading…
Add table
Reference in a new issue