mirror of
https://github.com/no2chem/wideq.git
synced 2025-05-21 09:30:13 -07:00
Addressing PR comments.
This commit is contained in:
parent
763d9f9887
commit
8ed1ae3c1b
@ -11,8 +11,8 @@ requires = [
|
|||||||
"requests"
|
"requests"
|
||||||
]
|
]
|
||||||
description-file = "README.md"
|
description-file = "README.md"
|
||||||
requires-python = ">=3.4"
|
requires-python = ">=3.5"
|
||||||
|
\be
|
||||||
[tool.flit.metadata.requires-extra]
|
[tool.flit.metadata.requires-extra]
|
||||||
test = [
|
test = [
|
||||||
"responses"
|
"responses"
|
||||||
|
@ -12,8 +12,8 @@ POLL_DATA = {
|
|||||||
'CurrentDownloadCourse': '100',
|
'CurrentDownloadCourse': '100',
|
||||||
'DryLevel': '3',
|
'DryLevel': '3',
|
||||||
'Error': '0',
|
'Error': '0',
|
||||||
'Initial_Time_H': '0',
|
'Initial_Time_H': '1',
|
||||||
'Initial_Time_M': '55',
|
'Initial_Time_M': '11',
|
||||||
'LoadItem': '0',
|
'LoadItem': '0',
|
||||||
'MoreLessTime': '0',
|
'MoreLessTime': '0',
|
||||||
'Option1': '0',
|
'Option1': '0',
|
||||||
@ -55,10 +55,8 @@ class DryerStatusTest(unittest.TestCase):
|
|||||||
self.assertEqual(DryerState.INITIAL, status.previous_state)
|
self.assertEqual(DryerState.INITIAL, status.previous_state)
|
||||||
self.assertEqual(DryLevel.NORMAL, status.dry_level)
|
self.assertEqual(DryLevel.NORMAL, status.dry_level)
|
||||||
self.assertTrue(status.is_on)
|
self.assertTrue(status.is_on)
|
||||||
self.assertEqual('0', status.remain_time_hours)
|
self.assertEqual(54, status.remaining_time)
|
||||||
self.assertEqual('54', status.remain_time_minutes)
|
self.assertEqual(71, status.initial_time)
|
||||||
self.assertEqual('0', status.initial_time_hours)
|
|
||||||
self.assertEqual('55', status.initial_time_minutes)
|
|
||||||
self.assertEqual('Towels', status.course)
|
self.assertEqual('Towels', status.course)
|
||||||
self.assertEqual('Off', status.smart_course)
|
self.assertEqual('Off', status.smart_course)
|
||||||
self.assertEqual('No Error', status.error)
|
self.assertEqual('No Error', status.error)
|
||||||
|
@ -365,7 +365,8 @@ class ModelInfo(object):
|
|||||||
|
|
||||||
:param key: The referenced key.
|
:param key: The referenced key.
|
||||||
:param value: The value whose name we want to look up.
|
:param value: The value whose name we want to look up.
|
||||||
:returns: The friendly name for the referenced value.
|
:returns: The friendly name for the referenced value. If no name
|
||||||
|
can be found `-` will be returned.
|
||||||
"""
|
"""
|
||||||
value = str(value)
|
value = str(value)
|
||||||
reference = self.value(key).reference
|
reference = self.value(key).reference
|
||||||
|
@ -84,7 +84,7 @@ class TimeDry(enum.Enum):
|
|||||||
class DryerDevice(Device):
|
class DryerDevice(Device):
|
||||||
"""A higher-level interface for a dryer."""
|
"""A higher-level interface for a dryer."""
|
||||||
|
|
||||||
def poll(self) -> Optional['DryerDevice']:
|
def poll(self) -> Optional['DryerStatus']:
|
||||||
"""Poll the device's current state.
|
"""Poll the device's current state.
|
||||||
|
|
||||||
Monitoring must be started first with `monitor_start`.
|
Monitoring must be started first with `monitor_start`.
|
||||||
@ -123,35 +123,38 @@ class DryerStatus(object):
|
|||||||
else:
|
else:
|
||||||
return 'ON'
|
return 'ON'
|
||||||
|
|
||||||
|
def _lookup_enum(self, attr: str) -> str:
|
||||||
|
"""Looks up an enum value for the provided attr.
|
||||||
|
|
||||||
|
:param attr: The attribute to lookup in the enum.
|
||||||
|
:returns: The enum value.
|
||||||
|
"""
|
||||||
|
return self.dryer.model.enum_name(attr, self.data[attr])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self) -> DryerState:
|
def state(self) -> DryerState:
|
||||||
"""Get the state of the dryer."""
|
"""Get the state of the dryer."""
|
||||||
attr = 'State'
|
return DryerState(self._lookup_enum('State'))
|
||||||
return DryerState(self.dryer.model.enum_name(attr, self.data[attr]))
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def previous_state(self) -> DryerState:
|
def previous_state(self) -> DryerState:
|
||||||
"""Get the previous state of the dryer."""
|
"""Get the previous state of the dryer."""
|
||||||
attr = 'PreState'
|
return DryerState(self._lookup_enum('PreState'))
|
||||||
return DryerState(self.dryer.model.enum_name(attr, self.data[attr]))
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def dry_level(self) -> DryLevel:
|
def dry_level(self) -> DryLevel:
|
||||||
"""Get the dry level."""
|
"""Get the dry level."""
|
||||||
attr = 'DryLevel'
|
return DryLevel(self._lookup_enum('DryLevel'))
|
||||||
return DryLevel(self.dryer.model.enum_name(attr, self.data[attr]))
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def temperature_control(self) -> TempControl:
|
def temperature_control(self) -> TempControl:
|
||||||
"""Get the temperature control setting."""
|
"""Get the temperature control setting."""
|
||||||
attr = 'TempControl'
|
return TempControl(self._lookup_enum('TempControl'))
|
||||||
return TempControl(self.dryer.model.enum_name(attr, self.data[attr]))
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def time_dry(self) -> TimeDry:
|
def time_dry(self) -> TimeDry:
|
||||||
"""Get the time dry setting."""
|
"""Get the time dry setting."""
|
||||||
attr = 'TimeDry'
|
return TimeDry(self._lookup_enum('TimeDry'))
|
||||||
return TimeDry(self.dryer.model.enum_name(attr, self.data[attr]))
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
@ -159,24 +162,17 @@ class DryerStatus(object):
|
|||||||
return self.state != DryerState.OFF
|
return self.state != DryerState.OFF
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def remain_time_hours(self):
|
def remaining_time(self):
|
||||||
"""Get the remaining number of hours."""
|
"""Get the remaining time in minutes."""
|
||||||
return self.data['Remain_Time_H']
|
return (int(self.data['Remain_Time_H']) * 60 +
|
||||||
|
int(self.data['Remain_Time_M']))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def remain_time_minutes(self):
|
def initial_time(self):
|
||||||
"""Get the remaining number of minutes."""
|
"""Get the initial time in minutes."""
|
||||||
return self.data['Remain_Time_M']
|
return (
|
||||||
|
int(self.data['Initial_Time_H']) * 60 +
|
||||||
@property
|
int(self.data['Initial_Time_M']))
|
||||||
def initial_time_hours(self):
|
|
||||||
"""Get the initial number of hours."""
|
|
||||||
return self.data['Initial_Time_H']
|
|
||||||
|
|
||||||
@property
|
|
||||||
def initial_time_minutes(self):
|
|
||||||
"""Get the initial number of minutes."""
|
|
||||||
return self.data['Initial_Time_M']
|
|
||||||
|
|
||||||
def _lookup_reference(self, attr: str) -> str:
|
def _lookup_reference(self, attr: str) -> str:
|
||||||
"""Look up a reference value for the provided attribute.
|
"""Look up a reference value for the provided attribute.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user