99 lines
3.5 KiB
Python
99 lines
3.5 KiB
Python
|
import logging
|
||
|
from .message import (
|
||
|
MessageQuery,
|
||
|
MessageCAResponse
|
||
|
)
|
||
|
try:
|
||
|
from enum import StrEnum
|
||
|
except ImportError:
|
||
|
from ...backports.enum import StrEnum
|
||
|
from ...core.device import MiedaDevice
|
||
|
|
||
|
_LOGGER = logging.getLogger(__name__)
|
||
|
|
||
|
|
||
|
class DeviceAttributes(StrEnum):
|
||
|
mode = "mode"
|
||
|
energy_consumption = "energy_consumption"
|
||
|
refrigerator_actual_temp = "refrigerator_actual_temp"
|
||
|
freezer_actual_temp = "freezer_actual_temp"
|
||
|
flex_zone_actual_temp = "flex_zone_actual_temp"
|
||
|
right_flex_zone_actual_temp = "right_flex_zone_actual_temp"
|
||
|
refrigerator_setting_temp = "refrigerator_setting_temp"
|
||
|
freezer_setting_temp = "freezer_setting_temp"
|
||
|
flex_zone_setting_temp = "flex_zone_setting_temp"
|
||
|
right_flex_zone_setting_temp = "right_flex_zone_setting_temp"
|
||
|
refrigerator_door_overtime = "refrigerator_door_overtime"
|
||
|
freezer_door_overtime = "freezer_door_overtime"
|
||
|
bar_door_overtime = "bar_door_overtime"
|
||
|
flex_zone_door_overtime = "flex_zone_door_overtime"
|
||
|
refrigerator_door = "refrigerator_door"
|
||
|
freezer_door = "freezer_door"
|
||
|
bar_door = "bar_door"
|
||
|
flex_zone_door = "flex_zone_door"
|
||
|
|
||
|
|
||
|
class MideaCADevice(MiedaDevice):
|
||
|
def __init__(
|
||
|
self,
|
||
|
name: str,
|
||
|
device_id: int,
|
||
|
ip_address: str,
|
||
|
port: int,
|
||
|
token: str,
|
||
|
key: str,
|
||
|
protocol: int,
|
||
|
model: str,
|
||
|
customize: str
|
||
|
):
|
||
|
super().__init__(
|
||
|
name=name,
|
||
|
device_id=device_id,
|
||
|
device_type=0xCA,
|
||
|
ip_address=ip_address,
|
||
|
port=port,
|
||
|
token=token,
|
||
|
key=key,
|
||
|
protocol=protocol,
|
||
|
model=model,
|
||
|
attributes={
|
||
|
DeviceAttributes.energy_consumption: None,
|
||
|
DeviceAttributes.refrigerator_actual_temp: None,
|
||
|
DeviceAttributes.freezer_actual_temp: None,
|
||
|
DeviceAttributes.flex_zone_actual_temp: None,
|
||
|
DeviceAttributes.right_flex_zone_actual_temp: None,
|
||
|
DeviceAttributes.refrigerator_setting_temp: None,
|
||
|
DeviceAttributes.freezer_setting_temp: None,
|
||
|
DeviceAttributes.flex_zone_setting_temp: None,
|
||
|
DeviceAttributes.right_flex_zone_setting_temp: None,
|
||
|
DeviceAttributes.refrigerator_door_overtime: False,
|
||
|
DeviceAttributes.freezer_door_overtime: False,
|
||
|
DeviceAttributes.bar_door_overtime: False,
|
||
|
DeviceAttributes.flex_zone_door_overtime: False,
|
||
|
DeviceAttributes.refrigerator_door: False,
|
||
|
DeviceAttributes.freezer_door: False,
|
||
|
DeviceAttributes.bar_door: False,
|
||
|
DeviceAttributes.flex_zone_door: False
|
||
|
})
|
||
|
self._modes = [""]
|
||
|
|
||
|
def build_query(self):
|
||
|
return [MessageQuery(self._device_protocol_version)]
|
||
|
|
||
|
def process_message(self, msg):
|
||
|
message = MessageCAResponse(msg)
|
||
|
_LOGGER.debug(f"[{self.device_id}] Received: {message}")
|
||
|
new_status = {}
|
||
|
for status in self._attributes.keys():
|
||
|
if hasattr(message, str(status)):
|
||
|
self._attributes[status] = getattr(message, str(status))
|
||
|
new_status[str(status)] = getattr(message, str(status))
|
||
|
return new_status
|
||
|
|
||
|
def set_attribute(self, attr, value):
|
||
|
pass
|
||
|
|
||
|
|
||
|
class MideaAppliance(MideaCADevice):
|
||
|
pass
|