Add unit of measurement to translations for Mastodon (#131343)

* Add unit of measurement to translations

* Fix strings lint
pull/131382/head
Andrew Jackson 2024-11-23 17:00:28 +00:00 committed by GitHub
parent 7b70f2d83b
commit f93525e0fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 12 deletions

View File

@ -35,21 +35,18 @@ ENTITY_DESCRIPTIONS = (
MastodonSensorEntityDescription(
key="followers",
translation_key="followers",
native_unit_of_measurement="accounts",
state_class=SensorStateClass.TOTAL,
value_fn=lambda data: data.get(ACCOUNT_FOLLOWERS_COUNT),
),
MastodonSensorEntityDescription(
key="following",
translation_key="following",
native_unit_of_measurement="accounts",
state_class=SensorStateClass.TOTAL,
value_fn=lambda data: data.get(ACCOUNT_FOLLOWING_COUNT),
),
MastodonSensorEntityDescription(
key="posts",
translation_key="posts",
native_unit_of_measurement="posts",
state_class=SensorStateClass.TOTAL,
value_fn=lambda data: data.get(ACCOUNT_STATUSES_COUNT),
),

View File

@ -42,13 +42,16 @@
"entity": {
"sensor": {
"followers": {
"name": "Followers"
"name": "Followers",
"unit_of_measurement": "accounts"
},
"following": {
"name": "Following"
"name": "Following",
"unit_of_measurement": "[%key:component::mastodon::entity::sensor::followers::unit_of_measurement%]"
},
"posts": {
"name": "Posts"
"name": "Posts",
"unit_of_measurement": "posts"
}
}
}

View File

@ -31,7 +31,7 @@
'supported_features': 0,
'translation_key': 'followers',
'unique_id': 'trwnh_mastodon_social_followers',
'unit_of_measurement': 'accounts',
'unit_of_measurement': None,
})
# ---
# name: test_sensors[sensor.mastodon_trwnh_mastodon_social_followers-state]
@ -39,7 +39,6 @@
'attributes': ReadOnlyDict({
'friendly_name': 'Mastodon @trwnh@mastodon.social Followers',
'state_class': <SensorStateClass.TOTAL: 'total'>,
'unit_of_measurement': 'accounts',
}),
'context': <ANY>,
'entity_id': 'sensor.mastodon_trwnh_mastodon_social_followers',
@ -81,7 +80,7 @@
'supported_features': 0,
'translation_key': 'following',
'unique_id': 'trwnh_mastodon_social_following',
'unit_of_measurement': 'accounts',
'unit_of_measurement': None,
})
# ---
# name: test_sensors[sensor.mastodon_trwnh_mastodon_social_following-state]
@ -89,7 +88,6 @@
'attributes': ReadOnlyDict({
'friendly_name': 'Mastodon @trwnh@mastodon.social Following',
'state_class': <SensorStateClass.TOTAL: 'total'>,
'unit_of_measurement': 'accounts',
}),
'context': <ANY>,
'entity_id': 'sensor.mastodon_trwnh_mastodon_social_following',
@ -131,7 +129,7 @@
'supported_features': 0,
'translation_key': 'posts',
'unique_id': 'trwnh_mastodon_social_posts',
'unit_of_measurement': 'posts',
'unit_of_measurement': None,
})
# ---
# name: test_sensors[sensor.mastodon_trwnh_mastodon_social_posts-state]
@ -139,7 +137,6 @@
'attributes': ReadOnlyDict({
'friendly_name': 'Mastodon @trwnh@mastodon.social Posts',
'state_class': <SensorStateClass.TOTAL: 'total'>,
'unit_of_measurement': 'posts',
}),
'context': <ANY>,
'entity_id': 'sensor.mastodon_trwnh_mastodon_social_posts',