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