Home Assistant Unofficial Reference 2024.12.1
const.py
Go to the documentation of this file.
1 """Constants for the Transmission Bittorrent Client component."""
2 
3 from __future__ import annotations
4 
5 from collections.abc import Callable
6 
7 from transmission_rpc import Torrent
8 
9 DOMAIN = "transmission"
10 
11 ORDER_NEWEST_FIRST = "newest_first"
12 ORDER_OLDEST_FIRST = "oldest_first"
13 ORDER_BEST_RATIO_FIRST = "best_ratio_first"
14 ORDER_WORST_RATIO_FIRST = "worst_ratio_first"
15 
16 SUPPORTED_ORDER_MODES: dict[str, Callable[[list[Torrent]], list[Torrent]]] = {
17  ORDER_NEWEST_FIRST: lambda torrents: sorted(
18  torrents, key=lambda t: t.added_date, reverse=True
19  ),
20  ORDER_OLDEST_FIRST: lambda torrents: sorted(torrents, key=lambda t: t.added_date),
21  ORDER_WORST_RATIO_FIRST: lambda torrents: sorted(torrents, key=lambda t: t.ratio),
22  ORDER_BEST_RATIO_FIRST: lambda torrents: sorted(
23  torrents, key=lambda t: t.ratio, reverse=True
24  ),
25 }
26 CONF_ENTRY_ID = "entry_id"
27 CONF_LIMIT = "limit"
28 CONF_ORDER = "order"
29 
30 DEFAULT_DELETE_DATA = False
31 DEFAULT_LIMIT = 10
32 DEFAULT_ORDER = ORDER_OLDEST_FIRST
33 DEFAULT_NAME = "Transmission"
34 DEFAULT_SSL = False
35 DEFAULT_PORT = 9091
36 DEFAULT_PATH = "/transmission/rpc"
37 DEFAULT_SCAN_INTERVAL = 120
38 
39 STATE_ATTR_TORRENT_INFO = "torrent_info"
40 
41 ATTR_DELETE_DATA = "delete_data"
42 ATTR_TORRENT = "torrent"
43 
44 SERVICE_ADD_TORRENT = "add_torrent"
45 SERVICE_REMOVE_TORRENT = "remove_torrent"
46 SERVICE_START_TORRENT = "start_torrent"
47 SERVICE_STOP_TORRENT = "stop_torrent"
48 
49 EVENT_STARTED_TORRENT = "transmission_started_torrent"
50 EVENT_REMOVED_TORRENT = "transmission_removed_torrent"
51 EVENT_DOWNLOADED_TORRENT = "transmission_downloaded_torrent"
52 
53 STATE_UP_DOWN = "up_down"
54 STATE_SEEDING = "seeding"
55 STATE_DOWNLOADING = "downloading"