Skip to content

Commit

Permalink
Add translated native unit of measurement - QBitTorrent (#131918)
Browse files Browse the repository at this point in the history
Co-authored-by: epenet <[email protected]>
  • Loading branch information
andrew-codechimp and epenet authored Dec 2, 2024
1 parent 8d14930 commit 66d0d2e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 0 additions & 4 deletions homeassistant/components/qbittorrent/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,29 +100,25 @@ class QBittorrentSensorEntityDescription(SensorEntityDescription):
QBittorrentSensorEntityDescription(
key=SENSOR_TYPE_ALL_TORRENTS,
translation_key="all_torrents",
native_unit_of_measurement="torrents",
value_fn=lambda coordinator: count_torrents_in_states(coordinator, []),
),
QBittorrentSensorEntityDescription(
key=SENSOR_TYPE_ACTIVE_TORRENTS,
translation_key="active_torrents",
native_unit_of_measurement="torrents",
value_fn=lambda coordinator: count_torrents_in_states(
coordinator, ["downloading", "uploading"]
),
),
QBittorrentSensorEntityDescription(
key=SENSOR_TYPE_INACTIVE_TORRENTS,
translation_key="inactive_torrents",
native_unit_of_measurement="torrents",
value_fn=lambda coordinator: count_torrents_in_states(
coordinator, ["stalledDL", "stalledUP"]
),
),
QBittorrentSensorEntityDescription(
key=SENSOR_TYPE_PAUSED_TORRENTS,
translation_key="paused_torrents",
native_unit_of_measurement="torrents",
value_fn=lambda coordinator: count_torrents_in_states(
coordinator, ["pausedDL", "pausedUP"]
),
Expand Down
12 changes: 8 additions & 4 deletions homeassistant/components/qbittorrent/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,20 @@
}
},
"active_torrents": {
"name": "Active torrents"
"name": "Active torrents",
"unit_of_measurement": "torrents"
},
"inactive_torrents": {
"name": "Inactive torrents"
"name": "Inactive torrents",
"unit_of_measurement": "[%key:component::qbittorrent::entity::sensor::active_torrents::unit_of_measurement%]"
},
"paused_torrents": {
"name": "Paused torrents"
"name": "Paused torrents",
"unit_of_measurement": "[%key:component::qbittorrent::entity::sensor::active_torrents::unit_of_measurement%]"
},
"all_torrents": {
"name": "All torrents"
"name": "All torrents",
"unit_of_measurement": "[%key:component::qbittorrent::entity::sensor::active_torrents::unit_of_measurement%]"
}
},
"switch": {
Expand Down

0 comments on commit 66d0d2e

Please sign in to comment.