Add unit of measurement to translations for Mastodon (#131343)
* Add unit of measurement to translations * Fix strings lintpull/131382/head
parent
7b70f2d83b
commit
f93525e0fc
|
@ -35,21 +35,18 @@ ENTITY_DESCRIPTIONS = (
|
||||||
MastodonSensorEntityDescription(
|
MastodonSensorEntityDescription(
|
||||||
key="followers",
|
key="followers",
|
||||||
translation_key="followers",
|
translation_key="followers",
|
||||||
native_unit_of_measurement="accounts",
|
|
||||||
state_class=SensorStateClass.TOTAL,
|
state_class=SensorStateClass.TOTAL,
|
||||||
value_fn=lambda data: data.get(ACCOUNT_FOLLOWERS_COUNT),
|
value_fn=lambda data: data.get(ACCOUNT_FOLLOWERS_COUNT),
|
||||||
),
|
),
|
||||||
MastodonSensorEntityDescription(
|
MastodonSensorEntityDescription(
|
||||||
key="following",
|
key="following",
|
||||||
translation_key="following",
|
translation_key="following",
|
||||||
native_unit_of_measurement="accounts",
|
|
||||||
state_class=SensorStateClass.TOTAL,
|
state_class=SensorStateClass.TOTAL,
|
||||||
value_fn=lambda data: data.get(ACCOUNT_FOLLOWING_COUNT),
|
value_fn=lambda data: data.get(ACCOUNT_FOLLOWING_COUNT),
|
||||||
),
|
),
|
||||||
MastodonSensorEntityDescription(
|
MastodonSensorEntityDescription(
|
||||||
key="posts",
|
key="posts",
|
||||||
translation_key="posts",
|
translation_key="posts",
|
||||||
native_unit_of_measurement="posts",
|
|
||||||
state_class=SensorStateClass.TOTAL,
|
state_class=SensorStateClass.TOTAL,
|
||||||
value_fn=lambda data: data.get(ACCOUNT_STATUSES_COUNT),
|
value_fn=lambda data: data.get(ACCOUNT_STATUSES_COUNT),
|
||||||
),
|
),
|
||||||
|
|
|
@ -42,13 +42,16 @@
|
||||||
"entity": {
|
"entity": {
|
||||||
"sensor": {
|
"sensor": {
|
||||||
"followers": {
|
"followers": {
|
||||||
"name": "Followers"
|
"name": "Followers",
|
||||||
|
"unit_of_measurement": "accounts"
|
||||||
},
|
},
|
||||||
"following": {
|
"following": {
|
||||||
"name": "Following"
|
"name": "Following",
|
||||||
|
"unit_of_measurement": "[%key:component::mastodon::entity::sensor::followers::unit_of_measurement%]"
|
||||||
},
|
},
|
||||||
"posts": {
|
"posts": {
|
||||||
"name": "Posts"
|
"name": "Posts",
|
||||||
|
"unit_of_measurement": "posts"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
'translation_key': 'followers',
|
'translation_key': 'followers',
|
||||||
'unique_id': 'trwnh_mastodon_social_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]
|
# name: test_sensors[sensor.mastodon_trwnh_mastodon_social_followers-state]
|
||||||
|
@ -39,7 +39,6 @@
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'friendly_name': 'Mastodon @trwnh@mastodon.social Followers',
|
'friendly_name': 'Mastodon @trwnh@mastodon.social Followers',
|
||||||
'state_class': <SensorStateClass.TOTAL: 'total'>,
|
'state_class': <SensorStateClass.TOTAL: 'total'>,
|
||||||
'unit_of_measurement': 'accounts',
|
|
||||||
}),
|
}),
|
||||||
'context': <ANY>,
|
'context': <ANY>,
|
||||||
'entity_id': 'sensor.mastodon_trwnh_mastodon_social_followers',
|
'entity_id': 'sensor.mastodon_trwnh_mastodon_social_followers',
|
||||||
|
@ -81,7 +80,7 @@
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
'translation_key': 'following',
|
'translation_key': 'following',
|
||||||
'unique_id': 'trwnh_mastodon_social_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]
|
# name: test_sensors[sensor.mastodon_trwnh_mastodon_social_following-state]
|
||||||
|
@ -89,7 +88,6 @@
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'friendly_name': 'Mastodon @trwnh@mastodon.social Following',
|
'friendly_name': 'Mastodon @trwnh@mastodon.social Following',
|
||||||
'state_class': <SensorStateClass.TOTAL: 'total'>,
|
'state_class': <SensorStateClass.TOTAL: 'total'>,
|
||||||
'unit_of_measurement': 'accounts',
|
|
||||||
}),
|
}),
|
||||||
'context': <ANY>,
|
'context': <ANY>,
|
||||||
'entity_id': 'sensor.mastodon_trwnh_mastodon_social_following',
|
'entity_id': 'sensor.mastodon_trwnh_mastodon_social_following',
|
||||||
|
@ -131,7 +129,7 @@
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
'translation_key': 'posts',
|
'translation_key': 'posts',
|
||||||
'unique_id': 'trwnh_mastodon_social_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]
|
# name: test_sensors[sensor.mastodon_trwnh_mastodon_social_posts-state]
|
||||||
|
@ -139,7 +137,6 @@
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'friendly_name': 'Mastodon @trwnh@mastodon.social Posts',
|
'friendly_name': 'Mastodon @trwnh@mastodon.social Posts',
|
||||||
'state_class': <SensorStateClass.TOTAL: 'total'>,
|
'state_class': <SensorStateClass.TOTAL: 'total'>,
|
||||||
'unit_of_measurement': 'posts',
|
|
||||||
}),
|
}),
|
||||||
'context': <ANY>,
|
'context': <ANY>,
|
||||||
'entity_id': 'sensor.mastodon_trwnh_mastodon_social_posts',
|
'entity_id': 'sensor.mastodon_trwnh_mastodon_social_posts',
|
||||||
|
|
Loading…
Reference in New Issue