Skip to content

Commit

Permalink
Add unit of measurement to translations for Mealie (#131345)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-codechimp authored Nov 26, 2024
1 parent 9a46135 commit 4e9f03a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
5 changes: 0 additions & 5 deletions homeassistant/components/mealie/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand Down
15 changes: 10 additions & 5 deletions homeassistant/components/mealie/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
},
Expand Down
15 changes: 5 additions & 10 deletions tests/components/mealie/snapshots/test_sensor.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@
'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]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Mealie Categories',
'state_class': <SensorStateClass.TOTAL: 'total'>,
'unit_of_measurement': 'categories',
}),
'context': <ANY>,
'entity_id': 'sensor.mealie_categories',
Expand Down Expand Up @@ -81,15 +80,14 @@
'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]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Mealie Recipes',
'state_class': <SensorStateClass.TOTAL: 'total'>,
'unit_of_measurement': 'recipes',
}),
'context': <ANY>,
'entity_id': 'sensor.mealie_recipes',
Expand Down Expand Up @@ -131,15 +129,14 @@
'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]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Mealie Tags',
'state_class': <SensorStateClass.TOTAL: 'total'>,
'unit_of_measurement': 'tags',
}),
'context': <ANY>,
'entity_id': 'sensor.mealie_tags',
Expand Down Expand Up @@ -181,15 +178,14 @@
'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]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Mealie Tools',
'state_class': <SensorStateClass.TOTAL: 'total'>,
'unit_of_measurement': 'tools',
}),
'context': <ANY>,
'entity_id': 'sensor.mealie_tools',
Expand Down Expand Up @@ -231,15 +227,14 @@
'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]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Mealie Users',
'state_class': <SensorStateClass.TOTAL: 'total'>,
'unit_of_measurement': 'users',
}),
'context': <ANY>,
'entity_id': 'sensor.mealie_users',
Expand Down

0 comments on commit 4e9f03a

Please sign in to comment.