mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 10:47:10 +00:00
Merge pull request #153 from fbradyirl/transmission-turtle
Transmission turtle
This commit is contained in:
commit
3c31758826
@ -92,7 +92,6 @@ class TransmissionSwitch(ToggleEntity):
|
|||||||
def __init__(self, transmission_client, name):
|
def __init__(self, transmission_client, name):
|
||||||
self._name = name
|
self._name = name
|
||||||
self.transmission_client = transmission_client
|
self.transmission_client = transmission_client
|
||||||
self.turtle_mode_active = False
|
|
||||||
self._state = STATE_OFF
|
self._state = STATE_OFF
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -118,24 +117,19 @@ class TransmissionSwitch(ToggleEntity):
|
|||||||
""" Turn the device on. """
|
""" Turn the device on. """
|
||||||
|
|
||||||
_LOGGING.info("Turning on Turtle Mode")
|
_LOGGING.info("Turning on Turtle Mode")
|
||||||
self.toggle_turtle_mode()
|
self.transmission_client.set_session(
|
||||||
|
alt_speed_enabled=True)
|
||||||
|
|
||||||
def turn_off(self, **kwargs):
|
def turn_off(self, **kwargs):
|
||||||
""" Turn the device off. """
|
""" Turn the device off. """
|
||||||
|
|
||||||
_LOGGING.info("Turning off Turtle Mode ")
|
_LOGGING.info("Turning off Turtle Mode ")
|
||||||
self.toggle_turtle_mode()
|
|
||||||
|
|
||||||
def toggle_turtle_mode(self):
|
|
||||||
""" Toggle turtle mode. """
|
|
||||||
|
|
||||||
self.transmission_client.set_session(
|
self.transmission_client.set_session(
|
||||||
alt_speed_enabled=not self.turtle_mode_active)
|
alt_speed_enabled=False)
|
||||||
self.update()
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
""" Gets the latest data from Transmission and updates the state. """
|
""" Gets the latest data from Transmission and updates the state. """
|
||||||
|
|
||||||
self.turtle_mode_active = self.transmission_client.get_session(
|
active = self.transmission_client.get_session(
|
||||||
).alt_speed_enabled
|
).alt_speed_enabled
|
||||||
self._state = STATE_ON if self.turtle_mode_active else STATE_OFF
|
self._state = STATE_ON if active else STATE_OFF
|
||||||
|
Loading…
x
Reference in New Issue
Block a user