From f0eb0849088aa843d3ab8b479f2a734eeb3d6414 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Mon, 3 Jul 2023 18:31:07 +0200 Subject: [PATCH] Add entity translations to Notion (#95755) * Add entity translations to Notion * Use device class translations * Use device class translations --- .../components/notion/binary_sensor.py | 13 ++++-------- homeassistant/components/notion/sensor.py | 3 +-- homeassistant/components/notion/strings.json | 21 +++++++++++++++++++ 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/notion/binary_sensor.py b/homeassistant/components/notion/binary_sensor.py index f70af18c3e1..ff58d566a34 100644 --- a/homeassistant/components/notion/binary_sensor.py +++ b/homeassistant/components/notion/binary_sensor.py @@ -52,7 +52,6 @@ class NotionBinarySensorDescription( BINARY_SENSOR_DESCRIPTIONS = ( NotionBinarySensorDescription( key=SENSOR_BATTERY, - name="Low battery", device_class=BinarySensorDeviceClass.BATTERY, entity_category=EntityCategory.DIAGNOSTIC, listener_kind=ListenerKind.BATTERY, @@ -60,28 +59,24 @@ BINARY_SENSOR_DESCRIPTIONS = ( ), NotionBinarySensorDescription( key=SENSOR_DOOR, - name="Door", device_class=BinarySensorDeviceClass.DOOR, listener_kind=ListenerKind.DOOR, on_state="open", ), NotionBinarySensorDescription( key=SENSOR_GARAGE_DOOR, - name="Garage door", device_class=BinarySensorDeviceClass.GARAGE_DOOR, listener_kind=ListenerKind.GARAGE_DOOR, on_state="open", ), NotionBinarySensorDescription( key=SENSOR_LEAK, - name="Leak detector", device_class=BinarySensorDeviceClass.MOISTURE, listener_kind=ListenerKind.LEAK_STATUS, on_state="leak", ), NotionBinarySensorDescription( key=SENSOR_MISSING, - name="Missing", device_class=BinarySensorDeviceClass.CONNECTIVITY, entity_category=EntityCategory.DIAGNOSTIC, listener_kind=ListenerKind.CONNECTED, @@ -89,28 +84,28 @@ BINARY_SENSOR_DESCRIPTIONS = ( ), NotionBinarySensorDescription( key=SENSOR_SAFE, - name="Safe", + translation_key="safe", device_class=BinarySensorDeviceClass.DOOR, listener_kind=ListenerKind.SAFE, on_state="open", ), NotionBinarySensorDescription( key=SENSOR_SLIDING, - name="Sliding door/window", + translation_key="sliding_door_window", device_class=BinarySensorDeviceClass.DOOR, listener_kind=ListenerKind.SLIDING_DOOR_OR_WINDOW, on_state="open", ), NotionBinarySensorDescription( key=SENSOR_SMOKE_CO, - name="Smoke/Carbon monoxide detector", + translation_key="smoke_carbon_monoxide_detector", device_class=BinarySensorDeviceClass.SMOKE, listener_kind=ListenerKind.SMOKE, on_state="alarm", ), NotionBinarySensorDescription( key=SENSOR_WINDOW_HINGED, - name="Hinged window", + translation_key="hinged_window", listener_kind=ListenerKind.HINGED_WINDOW, on_state="open", ), diff --git a/homeassistant/components/notion/sensor.py b/homeassistant/components/notion/sensor.py index 6f011523a2a..4777cc94fbf 100644 --- a/homeassistant/components/notion/sensor.py +++ b/homeassistant/components/notion/sensor.py @@ -27,13 +27,12 @@ class NotionSensorDescription(SensorEntityDescription, NotionEntityDescriptionMi SENSOR_DESCRIPTIONS = ( NotionSensorDescription( key=SENSOR_MOLD, - name="Mold risk", + translation_key="mold_risk", icon="mdi:liquid-spot", listener_kind=ListenerKind.MOLD, ), NotionSensorDescription( key=SENSOR_TEMPERATURE, - name="Temperature", device_class=SensorDeviceClass.TEMPERATURE, native_unit_of_measurement=UnitOfTemperature.CELSIUS, state_class=SensorStateClass.MEASUREMENT, diff --git a/homeassistant/components/notion/strings.json b/homeassistant/components/notion/strings.json index 49721568ff2..24a06d7ee71 100644 --- a/homeassistant/components/notion/strings.json +++ b/homeassistant/components/notion/strings.json @@ -24,5 +24,26 @@ "already_configured": "[%key:common::config_flow::abort::already_configured_account%]", "reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]" } + }, + "entity": { + "binary_sensor": { + "safe": { + "name": "Safe" + }, + "sliding_door_window": { + "name": "Sliding door/window" + }, + "smoke_carbon_monoxide_detector": { + "name": "Smoke/Carbon monoxide detector" + }, + "hinged_window": { + "name": "Hinged window" + } + }, + "sensor": { + "mold_risk": { + "name": "Mold risk" + } + } } }