1 """Support for setting the Deluge BitTorrent client in Pause."""
3 from __future__
import annotations
12 from .
import DelugeConfigEntry
13 from .coordinator
import DelugeDataUpdateCoordinator
14 from .entity
import DelugeEntity
19 entry: DelugeConfigEntry,
20 async_add_entities: AddEntitiesCallback,
22 """Set up the Deluge switch."""
27 """Representation of a Deluge switch."""
31 def __init__(self, coordinator: DelugeDataUpdateCoordinator) ->
None:
32 """Initialize the Deluge switch."""
34 self.
_attr_unique_id_attr_unique_id = f
"{coordinator.config_entry.entry_id}_enabled"
37 """Turn the device on."""
38 torrent_ids = self.coordinator.api.call(
"core.get_session_state")
39 self.coordinator.api.call(
"core.resume_torrent", torrent_ids)
42 """Turn the device off."""
43 torrent_ids = self.coordinator.api.call(
"core.get_session_state")
44 self.coordinator.api.call(
"core.pause_torrent", torrent_ids)
48 """Return state of the switch."""
49 if self.coordinator.data:
50 data = self.coordinator.data[Platform.SWITCH]
51 for torrent
in data.values():
52 item = torrent.popitem()
None turn_off(self, **Any kwargs)
None __init__(self, DelugeDataUpdateCoordinator coordinator)
None turn_on(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, DelugeConfigEntry entry, AddEntitiesCallback async_add_entities)