mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Use torrent id to identify torrents that should trigger events (#118897)
This commit is contained in:
parent
a7429e5f50
commit
7337c13747
@ -93,16 +93,14 @@ class TransmissionDataUpdateCoordinator(DataUpdateCoordinator[SessionStats]):
|
|||||||
|
|
||||||
def check_completed_torrent(self) -> None:
|
def check_completed_torrent(self) -> None:
|
||||||
"""Get completed torrent functionality."""
|
"""Get completed torrent functionality."""
|
||||||
old_completed_torrent_names = {
|
old_completed_torrents = {torrent.id for torrent in self._completed_torrents}
|
||||||
torrent.name for torrent in self._completed_torrents
|
|
||||||
}
|
|
||||||
|
|
||||||
current_completed_torrents = [
|
current_completed_torrents = [
|
||||||
torrent for torrent in self.torrents if torrent.status == "seeding"
|
torrent for torrent in self.torrents if torrent.status == "seeding"
|
||||||
]
|
]
|
||||||
|
|
||||||
for torrent in current_completed_torrents:
|
for torrent in current_completed_torrents:
|
||||||
if torrent.name not in old_completed_torrent_names:
|
if torrent.id not in old_completed_torrents:
|
||||||
self.hass.bus.fire(
|
self.hass.bus.fire(
|
||||||
EVENT_DOWNLOADED_TORRENT, {"name": torrent.name, "id": torrent.id}
|
EVENT_DOWNLOADED_TORRENT, {"name": torrent.name, "id": torrent.id}
|
||||||
)
|
)
|
||||||
@ -111,14 +109,14 @@ class TransmissionDataUpdateCoordinator(DataUpdateCoordinator[SessionStats]):
|
|||||||
|
|
||||||
def check_started_torrent(self) -> None:
|
def check_started_torrent(self) -> None:
|
||||||
"""Get started torrent functionality."""
|
"""Get started torrent functionality."""
|
||||||
old_started_torrent_names = {torrent.name for torrent in self._started_torrents}
|
old_started_torrents = {torrent.id for torrent in self._started_torrents}
|
||||||
|
|
||||||
current_started_torrents = [
|
current_started_torrents = [
|
||||||
torrent for torrent in self.torrents if torrent.status == "downloading"
|
torrent for torrent in self.torrents if torrent.status == "downloading"
|
||||||
]
|
]
|
||||||
|
|
||||||
for torrent in current_started_torrents:
|
for torrent in current_started_torrents:
|
||||||
if torrent.name not in old_started_torrent_names:
|
if torrent.id not in old_started_torrents:
|
||||||
self.hass.bus.fire(
|
self.hass.bus.fire(
|
||||||
EVENT_STARTED_TORRENT, {"name": torrent.name, "id": torrent.id}
|
EVENT_STARTED_TORRENT, {"name": torrent.name, "id": torrent.id}
|
||||||
)
|
)
|
||||||
@ -127,10 +125,10 @@ class TransmissionDataUpdateCoordinator(DataUpdateCoordinator[SessionStats]):
|
|||||||
|
|
||||||
def check_removed_torrent(self) -> None:
|
def check_removed_torrent(self) -> None:
|
||||||
"""Get removed torrent functionality."""
|
"""Get removed torrent functionality."""
|
||||||
current_torrent_names = {torrent.name for torrent in self.torrents}
|
current_torrents = {torrent.id for torrent in self.torrents}
|
||||||
|
|
||||||
for torrent in self._all_torrents:
|
for torrent in self._all_torrents:
|
||||||
if torrent.name not in current_torrent_names:
|
if torrent.id not in current_torrents:
|
||||||
self.hass.bus.fire(
|
self.hass.bus.fire(
|
||||||
EVENT_REMOVED_TORRENT, {"name": torrent.name, "id": torrent.id}
|
EVENT_REMOVED_TORRENT, {"name": torrent.name, "id": torrent.id}
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user