Add entity translations to Guardian (#95411)

This commit is contained in:
Joost Lekkerkerker 2023-06-27 22:24:41 +02:00 committed by GitHub
parent bafb81337b
commit 21c619e702
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 11 deletions

View File

@ -49,12 +49,12 @@ class ValveControllerBinarySensorDescription(
PAIRED_SENSOR_DESCRIPTIONS = (
BinarySensorEntityDescription(
key=SENSOR_KIND_LEAK_DETECTED,
name="Leak detected",
translation_key="leak",
device_class=BinarySensorDeviceClass.MOISTURE,
),
BinarySensorEntityDescription(
key=SENSOR_KIND_MOVED,
name="Recently moved",
translation_key="moved",
device_class=BinarySensorDeviceClass.MOVING,
entity_category=EntityCategory.DIAGNOSTIC,
),
@ -63,7 +63,7 @@ PAIRED_SENSOR_DESCRIPTIONS = (
VALVE_CONTROLLER_DESCRIPTIONS = (
ValveControllerBinarySensorDescription(
key=SENSOR_KIND_LEAK_DETECTED,
name="Leak detected",
translation_key="leak",
device_class=BinarySensorDeviceClass.MOISTURE,
api_category=API_SYSTEM_ONBOARD_SENSOR_STATUS,
),

View File

@ -56,15 +56,15 @@ async def _async_valve_reset(client: Client) -> None:
BUTTON_DESCRIPTIONS = (
ValveControllerButtonDescription(
key=BUTTON_KIND_REBOOT,
name="Reboot",
push_action=_async_reboot,
device_class=ButtonDeviceClass.RESTART,
# Buttons don't actually need a coordinator; we give them one so they can
# properly inherit from GuardianEntity:
api_category=API_SYSTEM_DIAGNOSTICS,
),
ValveControllerButtonDescription(
key=BUTTON_KIND_RESET_VALVE_DIAGNOSTICS,
name="Reset valve diagnostics",
translation_key="reset_diagnostics",
push_action=_async_valve_reset,
# Buttons don't actually need a coordinator; we give them one so they can
# properly inherit from GuardianEntity:

View File

@ -49,14 +49,12 @@ class ValveControllerSensorDescription(
PAIRED_SENSOR_DESCRIPTIONS = (
SensorEntityDescription(
key=SENSOR_KIND_BATTERY,
name="Battery",
device_class=SensorDeviceClass.VOLTAGE,
entity_category=EntityCategory.DIAGNOSTIC,
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
),
SensorEntityDescription(
key=SENSOR_KIND_TEMPERATURE,
name="Temperature",
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT,
state_class=SensorStateClass.MEASUREMENT,
@ -65,7 +63,6 @@ PAIRED_SENSOR_DESCRIPTIONS = (
VALVE_CONTROLLER_DESCRIPTIONS = (
ValveControllerSensorDescription(
key=SENSOR_KIND_TEMPERATURE,
name="Temperature",
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT,
state_class=SensorStateClass.MEASUREMENT,
@ -73,7 +70,7 @@ VALVE_CONTROLLER_DESCRIPTIONS = (
),
ValveControllerSensorDescription(
key=SENSOR_KIND_UPTIME,
name="Uptime",
translation_key="uptime",
icon="mdi:timer",
entity_category=EntityCategory.DIAGNOSTIC,
native_unit_of_measurement=UnitOfTime.MINUTES,

View File

@ -30,5 +30,33 @@
}
}
}
},
"entity": {
"binary_sensor": {
"leak": {
"name": "Leak detected"
},
"moved": {
"name": "Recently moved"
}
},
"button": {
"reset_diagnostics": {
"name": "Reset valve diagnostics"
}
},
"sensor": {
"uptime": {
"name": "Uptime"
}
},
"switch": {
"onboard_access_point": {
"name": "Onboard access point"
},
"valve_controller": {
"name": "Valve controller"
}
}
}
}

View File

@ -67,7 +67,7 @@ async def _async_open_valve(client: Client) -> None:
VALVE_CONTROLLER_DESCRIPTIONS = (
ValveControllerSwitchDescription(
key=SWITCH_KIND_ONBOARD_AP,
name="Onboard AP",
translation_key="onboard_access_point",
icon="mdi:wifi",
entity_category=EntityCategory.CONFIG,
api_category=API_WIFI_STATUS,
@ -76,7 +76,7 @@ VALVE_CONTROLLER_DESCRIPTIONS = (
),
ValveControllerSwitchDescription(
key=SWITCH_KIND_VALVE,
name="Valve controller",
translation_key="valve_controller",
icon="mdi:water",
api_category=API_VALVE_STATUS,
off_action=_async_close_valve,