From 4e9f03a5ca5ddd8fbdc476807a772cb6552ea890 Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Tue, 26 Nov 2024 07:29:15 +0000 Subject: [PATCH] Add unit of measurement to translations for Mealie (#131345) --- homeassistant/components/mealie/sensor.py | 5 ----- homeassistant/components/mealie/strings.json | 15 ++++++++++----- .../components/mealie/snapshots/test_sensor.ambr | 15 +++++---------- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/homeassistant/components/mealie/sensor.py b/homeassistant/components/mealie/sensor.py index b4baac34ebef43..141a28ecdab83e 100644 --- a/homeassistant/components/mealie/sensor.py +++ b/homeassistant/components/mealie/sensor.py @@ -28,31 +28,26 @@ class MealieStatisticsSensorEntityDescription(SensorEntityDescription): SENSOR_TYPES: tuple[MealieStatisticsSensorEntityDescription, ...] = ( MealieStatisticsSensorEntityDescription( key="recipes", - native_unit_of_measurement="recipes", state_class=SensorStateClass.TOTAL, value_fn=lambda statistics: statistics.total_recipes, ), MealieStatisticsSensorEntityDescription( key="users", - native_unit_of_measurement="users", state_class=SensorStateClass.TOTAL, value_fn=lambda statistics: statistics.total_users, ), MealieStatisticsSensorEntityDescription( key="categories", - native_unit_of_measurement="categories", state_class=SensorStateClass.TOTAL, value_fn=lambda statistics: statistics.total_categories, ), MealieStatisticsSensorEntityDescription( key="tags", - native_unit_of_measurement="tags", state_class=SensorStateClass.TOTAL, value_fn=lambda statistics: statistics.total_tags, ), MealieStatisticsSensorEntityDescription( key="tools", - native_unit_of_measurement="tools", state_class=SensorStateClass.TOTAL, value_fn=lambda statistics: statistics.total_tools, ), diff --git a/homeassistant/components/mealie/strings.json b/homeassistant/components/mealie/strings.json index b59399815ea03a..5555d3ffa21f63 100644 --- a/homeassistant/components/mealie/strings.json +++ b/homeassistant/components/mealie/strings.json @@ -56,19 +56,24 @@ }, "sensor": { "recipes": { - "name": "Recipes" + "name": "Recipes", + "unit_of_measurement": "recipes" }, "users": { - "name": "Users" + "name": "Users", + "unit_of_measurement": "users" }, "categories": { - "name": "Categories" + "name": "Categories", + "unit_of_measurement": "categories" }, "tags": { - "name": "Tags" + "name": "Tags", + "unit_of_measurement": "tags" }, "tools": { - "name": "Tools" + "name": "Tools", + "unit_of_measurement": "tools" } } }, diff --git a/tests/components/mealie/snapshots/test_sensor.ambr b/tests/components/mealie/snapshots/test_sensor.ambr index e645cf4c45f3e1..d52ffc9a79a4e9 100644 --- a/tests/components/mealie/snapshots/test_sensor.ambr +++ b/tests/components/mealie/snapshots/test_sensor.ambr @@ -31,7 +31,7 @@ 'supported_features': 0, 'translation_key': 'categories', 'unique_id': 'bf1c62fe-4941-4332-9886-e54e88dbdba0_categories', - 'unit_of_measurement': 'categories', + 'unit_of_measurement': None, }) # --- # name: test_entities[sensor.mealie_categories-state] @@ -39,7 +39,6 @@ 'attributes': ReadOnlyDict({ 'friendly_name': 'Mealie Categories', 'state_class': , - 'unit_of_measurement': 'categories', }), 'context': , 'entity_id': 'sensor.mealie_categories', @@ -81,7 +80,7 @@ 'supported_features': 0, 'translation_key': 'recipes', 'unique_id': 'bf1c62fe-4941-4332-9886-e54e88dbdba0_recipes', - 'unit_of_measurement': 'recipes', + 'unit_of_measurement': None, }) # --- # name: test_entities[sensor.mealie_recipes-state] @@ -89,7 +88,6 @@ 'attributes': ReadOnlyDict({ 'friendly_name': 'Mealie Recipes', 'state_class': , - 'unit_of_measurement': 'recipes', }), 'context': , 'entity_id': 'sensor.mealie_recipes', @@ -131,7 +129,7 @@ 'supported_features': 0, 'translation_key': 'tags', 'unique_id': 'bf1c62fe-4941-4332-9886-e54e88dbdba0_tags', - 'unit_of_measurement': 'tags', + 'unit_of_measurement': None, }) # --- # name: test_entities[sensor.mealie_tags-state] @@ -139,7 +137,6 @@ 'attributes': ReadOnlyDict({ 'friendly_name': 'Mealie Tags', 'state_class': , - 'unit_of_measurement': 'tags', }), 'context': , 'entity_id': 'sensor.mealie_tags', @@ -181,7 +178,7 @@ 'supported_features': 0, 'translation_key': 'tools', 'unique_id': 'bf1c62fe-4941-4332-9886-e54e88dbdba0_tools', - 'unit_of_measurement': 'tools', + 'unit_of_measurement': None, }) # --- # name: test_entities[sensor.mealie_tools-state] @@ -189,7 +186,6 @@ 'attributes': ReadOnlyDict({ 'friendly_name': 'Mealie Tools', 'state_class': , - 'unit_of_measurement': 'tools', }), 'context': , 'entity_id': 'sensor.mealie_tools', @@ -231,7 +227,7 @@ 'supported_features': 0, 'translation_key': 'users', 'unique_id': 'bf1c62fe-4941-4332-9886-e54e88dbdba0_users', - 'unit_of_measurement': 'users', + 'unit_of_measurement': None, }) # --- # name: test_entities[sensor.mealie_users-state] @@ -239,7 +235,6 @@ 'attributes': ReadOnlyDict({ 'friendly_name': 'Mealie Users', 'state_class': , - 'unit_of_measurement': 'users', }), 'context': , 'entity_id': 'sensor.mealie_users',