Skip to content

Commit

Permalink
Add timer control (capped to 60 minutes)
Browse files Browse the repository at this point in the history
  • Loading branch information
daggelpop committed May 16, 2020
1 parent 8a1cd32 commit aea0dc3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
14 changes: 14 additions & 0 deletions DysonPureLinkPlugin/dyson_pure_link_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,20 @@ def set_standby_monitoring(self, mode):
return
self._change_state({'rhtm': mode})

def set_timer(self, duration):
"""
Duration: OFF | 0-539
"""
data = None

if duration in ("OFF", 0):
data = {"sltm": "OFF"}
elif type(duration) == int and (0 < duration < 540):
data = {"sltm": '{:04d}'.format(duration)}

if data and self._is_connected:
self._change_state(data)

def get_data(self):
return (self.state_data, self.sensor_data) if self.has_valid_data else tuple()

Expand Down
7 changes: 5 additions & 2 deletions DysonPureLinkPlugin/value_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def __init__(self, message, temperature_unit):
humidity = data['hact']
temperature = data['tact']
volatile_compounds = data['vact']
timer = data['sltm']
self.temperature_unit = temperature_unit

self.humidity = None if humidity == 'OFF' else int(humidity)
Expand All @@ -65,17 +66,19 @@ def __init__(self, message, temperature_unit):
self.temperature = conversion_function(float(temperature) / 10)
self.volatile_compounds = 0 if volatile_compounds == 'INIT' else int(volatile_compounds)
self.particles = int(data['pact'])
self.timer = 0 if timer == 'OFF' else int(timer)

def __repr__(self):
"""Return a String representation"""
if self.has_data:
return 'Temperature: {:.1f}°{}, Humidity: {} %, Humidex: {:.1f}, Volatile Compounds: {}, Particles: {}'.format(
return 'Temperature: {:.1f}°{}, Humidity: {} %, Humidex: {:.1f}, Volatile Compounds: {}, Particles: {}, Timer: {}'.format(
self.temperature,
self.temperature_unit,
self.humidity,
self.humidex,
self.volatile_compounds,
self.particles
self.particles,
self.timer,
)
else:
return 'Volatile Compounds: {}, Particles: {}'.format(
Expand Down

0 comments on commit aea0dc3

Please sign in to comment.