Skip to content

Commit 100c16e

Browse files
committed
Clarifying comments and tidying up nits
1 parent 7c68f62 commit 100c16e

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

tinytuya/Contrib/TowelRailHeaterDevice.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def get_operating_mode(self):
106106
return status[self.DPS_MODE]
107107

108108
def set_operating_mode(self, mode):
109-
if mode not in ("cold", "hot", "eco","auto"):
109+
if mode not in ("cold", "hot", "eco", "auto"):
110110
return
111111
self.set_value(self.DPS_MODE, mode)
112112

@@ -115,18 +115,22 @@ def get_current_state(self):
115115
return "On" if status[self.DPS_POWER] else "Off"
116116

117117
def tuya_duration_to_minutes(self, duration):
118-
return duration * 6 # Returns 10 for 1 hour, 15 for 1 hour 30, 20 for 2 hours and so on
118+
# The devices returns 10 for 1 hour, 15 for 1 hour 30, 20 for 2 hours
119+
# but it seems more intuitive to use minutes as our interface
120+
return duration * 6
119121

120122
def minutes_to_tuya_duration(self, duration):
121-
return int(duration / 6) # Returns 10 for 1 hour, 15 for 1 hour 30, 20 for 2 hours and so on
123+
# The device expects 10 for 1 hour, 15 for 1 hour 30, 20 for 2 hours
124+
# so we need to convert from minutes into this format
125+
return int(duration / 6)
122126

123127
def get_timer(self):
124128
status = self.status()["dps"]
125129
return self.tuya_duration_to_minutes(status[self.DPS_TIMER])
126130

127131
def set_timer(self, delay):
128-
if delay < 30 or delay > 8 * 60: #8 hours maximum
132+
if delay < 30 or delay > 8 * 60: # 8 hours maximum
129133
return
130-
if delay % 30 != 0
134+
if delay % 30 != 0:
131135
return
132136
self.set_value(self.DPS_TIMER, self.minutes_to_tuya_duration(delay))

0 commit comments

Comments
 (0)