Skip to content

Commit

Permalink
add Uploading sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-mc1 committed Dec 30, 2023
1 parent 461b4a8 commit 8c8dcfc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 5 additions & 5 deletions custom_components/qbittorrent_alt/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ async def _async_update_data(self) -> dict[str, Any]:
seeding = 0
paused = 0
stalled = 0
uploading = 0
longest_eta = 0
for torrent in main_data.torrents.values():
if (
Expand All @@ -48,12 +49,10 @@ async def _async_update_data(self) -> dict[str, Any]:
or torrent["state"] == "forcedDL"
):
downloading += 1
if (
torrent["state"] == "uploading"
or torrent["state"] == "stalledUP"
or torrent["state"] == "forcedUP"
):
if torrent["state"] == "stalledUP" or torrent["state"] == "forcedUP":
seeding += 1
if torrent["state"] == "uploading":
uploading += 1
if torrent["state"] == "pausedUP" or torrent["state"] == "pausedDL":
paused += 1
if torrent["state"] == "stalledDL":
Expand All @@ -65,6 +64,7 @@ async def _async_update_data(self) -> dict[str, Any]:
"preferences": await self.client.app.preferences(),
"downloading": downloading,
"seeding": seeding,
"uploading": uploading,
"paused": paused,
"stalled": stalled,
"total": len(main_data.torrents),
Expand Down
7 changes: 7 additions & 0 deletions custom_components/qbittorrent_alt/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ class QBittorrentSensorEntityDescription(SensorEntityDescription, QBittorrentMix
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda coordinator: coordinator.data["seeding"],
),
QBittorrentSensorEntityDescription(
key="uploading",
name="Uploading",
icon="mdi:upload",
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda coordinator: coordinator.data["uploading"],
),
QBittorrentSensorEntityDescription(
key="paused",
name="Paused",
Expand Down

0 comments on commit 8c8dcfc

Please sign in to comment.