Module wideq.dishwasher
Expand source code
import enum
from typing import Optional
from .client import Device
from .util import lookup_enum, lookup_reference
class DishWasherState(enum.Enum):
"""The state of the dishwasher device."""
INITIAL = '@DW_STATE_INITIAL_W'
RUNNING = '@DW_STATE_RUNNING_W'
PAUSED = "@DW_STATE_PAUSE_W"
OFF = '@DW_STATE_POWER_OFF_W'
COMPLETE = '@DW_STATE_COMPLETE_W'
POWER_FAIL = "@DW_STATE_POWER_FAIL_W"
DISHWASHER_STATE_READABLE = {
'INITIAL': 'Standby',
'RUNNING': 'Running',
'PAUSED': 'Paused',
'OFF': 'Off',
'COMPLETE': 'Complete',
'POWER_FAIL': 'Power Failed'
}
class DishWasherProcess(enum.Enum):
"""The process within the dishwasher state."""
RESERVE = '@DW_STATE_RESERVE_W'
RUNNING = '@DW_STATE_RUNNING_W'
RINSING = '@DW_STATE_RINSING_W'
DRYING = '@DW_STATE_DRYING_W'
COMPLETE = '@DW_STATE_COMPLETE_W'
NIGHT_DRYING = '@DW_STATE_NIGHTDRY_W'
CANCELLED = '@DW_STATE_CANCEL_W'
DISHWASHER_PROCESS_READABLE = {
'RESERVE': 'Delayed Start',
'RUNNING': DISHWASHER_STATE_READABLE['RUNNING'],
'RINSING': 'Rinsing',
'DRYING': 'Drying',
'COMPLETE': DISHWASHER_STATE_READABLE['COMPLETE'],
'NIGHT_DRYING': 'Night Drying',
'CANCELLED': 'Cancelled',
}
# Provide a map to correct typos in the official course names.
DISHWASHER_COURSE_MAP = {
'Haeavy': 'Heavy',
}
class DishWasherDevice(Device):
"""A higher-level interface for a dishwasher."""
def poll(self) -> Optional['DishWasherStatus']:
"""Poll the device's current state.
Monitoring must be started first with `monitor_start`.
:returns: Either a `DishWasherStatus` instance or `None` if the status
is not yet available.
"""
# Abort if monitoring has not started yet.
if not hasattr(self, 'mon'):
return None
data = self.mon.poll()
if data:
res = self.model.decode_monitor(data)
return DishWasherStatus(self, res)
else:
return None
class DishWasherStatus(object):
"""Higher-level information about a dishwasher's current status.
:param dishwasher: The DishWasherDevice instance.
:param data: Binary data from the API.
"""
def __init__(self, dishwasher: DishWasherDevice, data: dict):
self.dishwasher = dishwasher
self.data = data
@property
def state(self) -> DishWasherState:
"""Get the state of the dishwasher."""
return DishWasherState(
lookup_enum('State', self.data, self.dishwasher))
@property
def readable_state(self) -> str:
"""Get a human readable state of the dishwasher."""
return DISHWASHER_STATE_READABLE[self.state.name]
@property
def process(self) -> Optional[DishWasherProcess]:
"""Get the process of the dishwasher."""
process = lookup_enum('Process', self.data, self.dishwasher)
if process and process != '-':
return DishWasherProcess(process)
else:
return None
@property
def readable_process(self) -> str:
"""Get a human readable process of the dishwasher."""
if self.process:
return DISHWASHER_PROCESS_READABLE[self.process.name]
else:
return ""
@property
def is_on(self) -> bool:
"""Check if the dishwasher is on or not."""
return self.state != DishWasherState.OFF
@property
def remaining_time(self) -> int:
"""Get the remaining time in minutes."""
return (int(self.data['Remain_Time_H']) * 60 +
int(self.data['Remain_Time_M']))
@property
def initial_time(self) -> int:
"""Get the initial time in minutes."""
return (
int(self.data['Initial_Time_H']) * 60 +
int(self.data['Initial_Time_M']))
@property
def reserve_time(self) -> int:
"""Get the reserve time in minutes."""
return (
int(self.data['Reserve_Time_H']) * 60 +
int(self.data['Reserve_Time_M']))
@property
def course(self) -> str:
"""Get the current course."""
course = lookup_reference('Course', self.data, self.dishwasher)
if course in DISHWASHER_COURSE_MAP:
return DISHWASHER_COURSE_MAP[course]
else:
return course
@property
def smart_course(self) -> str:
"""Get the current smart course."""
return lookup_reference('SmartCourse', self.data, self.dishwasher)
@property
def error(self) -> str:
"""Get the current error."""
return lookup_reference('Error', self.data, self.dishwasher)
Classes
class DishWasherDevice (client: Client, device: DeviceInfo)
-
A higher-level interface for a dishwasher.
Create a wrapper for a
DeviceInfo
object associated with aClient
.Expand source code
class DishWasherDevice(Device): """A higher-level interface for a dishwasher.""" def poll(self) -> Optional['DishWasherStatus']: """Poll the device's current state. Monitoring must be started first with `monitor_start`. :returns: Either a `DishWasherStatus` instance or `None` if the status is not yet available. """ # Abort if monitoring has not started yet. if not hasattr(self, 'mon'): return None data = self.mon.poll() if data: res = self.model.decode_monitor(data) return DishWasherStatus(self, res) else: return None
Ancestors
Methods
def poll(self) ‑> Union[DishWasherStatus, NoneType]
-
Poll the device's current state.
Monitoring must be started first with
monitor_start
.:returns: Either a
DishWasherStatus
instance orNone
if the status is not yet available.Expand source code
def poll(self) -> Optional['DishWasherStatus']: """Poll the device's current state. Monitoring must be started first with `monitor_start`. :returns: Either a `DishWasherStatus` instance or `None` if the status is not yet available. """ # Abort if monitoring has not started yet. if not hasattr(self, 'mon'): return None data = self.mon.poll() if data: res = self.model.decode_monitor(data) return DishWasherStatus(self, res) else: return None
Inherited members
class DishWasherProcess (value, names=None, *, module=None, qualname=None, type=None, start=1)
-
The process within the dishwasher state.
Expand source code
class DishWasherProcess(enum.Enum): """The process within the dishwasher state.""" RESERVE = '@DW_STATE_RESERVE_W' RUNNING = '@DW_STATE_RUNNING_W' RINSING = '@DW_STATE_RINSING_W' DRYING = '@DW_STATE_DRYING_W' COMPLETE = '@DW_STATE_COMPLETE_W' NIGHT_DRYING = '@DW_STATE_NIGHTDRY_W' CANCELLED = '@DW_STATE_CANCEL_W'
Ancestors
- enum.Enum
Class variables
var CANCELLED
var COMPLETE
var DRYING
var NIGHT_DRYING
var RESERVE
var RINSING
var RUNNING
class DishWasherState (value, names=None, *, module=None, qualname=None, type=None, start=1)
-
The state of the dishwasher device.
Expand source code
class DishWasherState(enum.Enum): """The state of the dishwasher device.""" INITIAL = '@DW_STATE_INITIAL_W' RUNNING = '@DW_STATE_RUNNING_W' PAUSED = "@DW_STATE_PAUSE_W" OFF = '@DW_STATE_POWER_OFF_W' COMPLETE = '@DW_STATE_COMPLETE_W' POWER_FAIL = "@DW_STATE_POWER_FAIL_W"
Ancestors
- enum.Enum
Class variables
var COMPLETE
var INITIAL
var OFF
var PAUSED
var POWER_FAIL
var RUNNING
class DishWasherStatus (dishwasher: DishWasherDevice, data: dict)
-
Higher-level information about a dishwasher's current status.
:param dishwasher: The DishWasherDevice instance. :param data: Binary data from the API.
Expand source code
class DishWasherStatus(object): """Higher-level information about a dishwasher's current status. :param dishwasher: The DishWasherDevice instance. :param data: Binary data from the API. """ def __init__(self, dishwasher: DishWasherDevice, data: dict): self.dishwasher = dishwasher self.data = data @property def state(self) -> DishWasherState: """Get the state of the dishwasher.""" return DishWasherState( lookup_enum('State', self.data, self.dishwasher)) @property def readable_state(self) -> str: """Get a human readable state of the dishwasher.""" return DISHWASHER_STATE_READABLE[self.state.name] @property def process(self) -> Optional[DishWasherProcess]: """Get the process of the dishwasher.""" process = lookup_enum('Process', self.data, self.dishwasher) if process and process != '-': return DishWasherProcess(process) else: return None @property def readable_process(self) -> str: """Get a human readable process of the dishwasher.""" if self.process: return DISHWASHER_PROCESS_READABLE[self.process.name] else: return "" @property def is_on(self) -> bool: """Check if the dishwasher is on or not.""" return self.state != DishWasherState.OFF @property def remaining_time(self) -> int: """Get the remaining time in minutes.""" return (int(self.data['Remain_Time_H']) * 60 + int(self.data['Remain_Time_M'])) @property def initial_time(self) -> int: """Get the initial time in minutes.""" return ( int(self.data['Initial_Time_H']) * 60 + int(self.data['Initial_Time_M'])) @property def reserve_time(self) -> int: """Get the reserve time in minutes.""" return ( int(self.data['Reserve_Time_H']) * 60 + int(self.data['Reserve_Time_M'])) @property def course(self) -> str: """Get the current course.""" course = lookup_reference('Course', self.data, self.dishwasher) if course in DISHWASHER_COURSE_MAP: return DISHWASHER_COURSE_MAP[course] else: return course @property def smart_course(self) -> str: """Get the current smart course.""" return lookup_reference('SmartCourse', self.data, self.dishwasher) @property def error(self) -> str: """Get the current error.""" return lookup_reference('Error', self.data, self.dishwasher)
Instance variables
var course : str
-
Get the current course.
Expand source code
@property def course(self) -> str: """Get the current course.""" course = lookup_reference('Course', self.data, self.dishwasher) if course in DISHWASHER_COURSE_MAP: return DISHWASHER_COURSE_MAP[course] else: return course
var error : str
-
Get the current error.
Expand source code
@property def error(self) -> str: """Get the current error.""" return lookup_reference('Error', self.data, self.dishwasher)
var initial_time : int
-
Get the initial time in minutes.
Expand source code
@property def initial_time(self) -> int: """Get the initial time in minutes.""" return ( int(self.data['Initial_Time_H']) * 60 + int(self.data['Initial_Time_M']))
var is_on : bool
-
Check if the dishwasher is on or not.
Expand source code
@property def is_on(self) -> bool: """Check if the dishwasher is on or not.""" return self.state != DishWasherState.OFF
var process : Union[DishWasherProcess, NoneType]
-
Get the process of the dishwasher.
Expand source code
@property def process(self) -> Optional[DishWasherProcess]: """Get the process of the dishwasher.""" process = lookup_enum('Process', self.data, self.dishwasher) if process and process != '-': return DishWasherProcess(process) else: return None
var readable_process : str
-
Get a human readable process of the dishwasher.
Expand source code
@property def readable_process(self) -> str: """Get a human readable process of the dishwasher.""" if self.process: return DISHWASHER_PROCESS_READABLE[self.process.name] else: return ""
var readable_state : str
-
Get a human readable state of the dishwasher.
Expand source code
@property def readable_state(self) -> str: """Get a human readable state of the dishwasher.""" return DISHWASHER_STATE_READABLE[self.state.name]
var remaining_time : int
-
Get the remaining time in minutes.
Expand source code
@property def remaining_time(self) -> int: """Get the remaining time in minutes.""" return (int(self.data['Remain_Time_H']) * 60 + int(self.data['Remain_Time_M']))
var reserve_time : int
-
Get the reserve time in minutes.
Expand source code
@property def reserve_time(self) -> int: """Get the reserve time in minutes.""" return ( int(self.data['Reserve_Time_H']) * 60 + int(self.data['Reserve_Time_M']))
var smart_course : str
-
Get the current smart course.
Expand source code
@property def smart_course(self) -> str: """Get the current smart course.""" return lookup_reference('SmartCourse', self.data, self.dishwasher)
var state : DishWasherState
-
Get the state of the dishwasher.
Expand source code
@property def state(self) -> DishWasherState: """Get the state of the dishwasher.""" return DishWasherState( lookup_enum('State', self.data, self.dishwasher))