wyzeapy.types
1# Copyright (c) 2021. Mulliken, LLC - All Rights Reserved 2# You may use, distribute and modify this code under the terms 3# of the attached license. You should have received a copy of 4# the license with this file. If not, please write to: 5# katie@mulliken.net to receive a copy 6from enum import Enum 7from typing import Union, List, Dict, Any 8 9 10class Group: 11 group_id: str 12 group_name: str 13 14 def __init__(self, dictionary: Dict[Any, Any]): 15 for k, v in dictionary.items(): 16 setattr(self, k, v) 17 18 def __repr__(self) -> str: 19 return "<Group: {}, {}>".format(self.group_id, self.group_name) 20 21 22class DeviceTypes(Enum): 23 LIGHT = "Light" 24 PLUG = "Plug" 25 OUTDOOR_PLUG = "OutdoorPlug" 26 MESH_LIGHT = "MeshLight" 27 CAMERA = "Camera" 28 CHIME_SENSOR = "ChimeSensor" 29 CONTACT_SENSOR = "ContactSensor" 30 MOTION_SENSOR = "MotionSensor" 31 LEAK_SENSOR = "LeakSensor" 32 WRIST = "Wrist" 33 BASE_STATION = "BaseStation" 34 SCALE = "WyzeScale" 35 LOCK = "Lock" 36 GATEWAY = "gateway" 37 COMMON = "Common" 38 VACUUM = "JA_RO2" 39 HEADPHONES = "JA.SC" 40 THERMOSTAT = "Thermostat" 41 GATEWAY_V2 = "GateWay" 42 UNKNOWN = "Unknown" 43 SENSE_V2_GATEWAY = "S1Gateway" 44 KEYPAD = "Keypad" 45 LIGHTSTRIP = "LightStrip" 46 47 48class Device: 49 product_type: str 50 product_model: str 51 mac: str 52 nickname: str 53 device_params: Dict[str, Any] 54 raw_dict: Dict[str, Any] 55 callback_function = None 56 57 def __init__(self, dictionary: Dict[Any, Any]): 58 self.available = False 59 60 self.raw_dict = dictionary 61 for k, v in dictionary.items(): 62 setattr(self, k, v) 63 64 @property 65 def type(self) -> DeviceTypes: 66 try: 67 return DeviceTypes(self.product_type) 68 except ValueError: 69 return DeviceTypes.UNKNOWN 70 71 def __repr__(self) -> str: 72 return "<Device: {}, {}>".format(DeviceTypes(self.product_type), self.mac) 73 74 75class Sensor(Device): 76 def __init__(self, dictionary: Dict[Any, Any]): 77 super().__init__(dictionary) 78 79 @property 80 def activity_detected(self) -> int: 81 if self.type is DeviceTypes.CONTACT_SENSOR: 82 return int(self.device_params['open_close_state']) 83 elif self.type is DeviceTypes.MOTION_SENSOR: 84 return int(self.device_params['motion_state']) 85 else: 86 raise AssertionError("Device must be of type CONTACT_SENSOR or MOTION_SENSOR") 87 88 @property 89 def is_low_battery(self) -> int: 90 return int(self.device_params['is_low_battery']) 91 92 93class PropertyIDs(Enum): 94 NOTIFICATION = "P1" 95 ON = "P3" 96 AVAILABLE = "P5" 97 BRIGHTNESS = "P1501" # From 0-100 98 COLOR_TEMP = "P1502" # In Kelvin 99 COLOR = "P1507" # As a hex string RrGgBb 100 COLOR_MODE = "P1508" # 1 = Basic Color, 2 = White, 3 = Effect Mode 101 LIGHTSTRIP_EFFECTS = "P1522" 102 LIGHTSTRIP_MUSIC_MODE = "P1535" 103 DOOR_OPEN = "P2001" # 0 if the door is closed 104 CONTACT_STATE = "P1301" 105 MOTION_STATE = "P1302" 106 CAMERA_SIREN = "P1049" 107 ACCESSORY = "P1056" # Is state for camera accessories, like garage doors, light sockets, and floodlights. 108 SUN_MATCH = "P1528" 109 MOTION_DETECTION = "P1047" # Current Motion Detection State of the Camera 110 MOTION_DETECTION_TOGGLE = "P1001" # This toggles Camera Motion Detection On/Off 111 WCO_MOTION_DETECTION = "P1029" # Wyze cam outdoor requires both P1047 and P1029 to be set. P1029 is set via set_property_list 112 113 114class WallSwitchProps(Enum): 115 IOT_STATE = "iot_state" # Connection state: connected, disconnected 116 SWITCH_POWER = "switch-power" 117 SWITCH_IOT = "switch-iot" 118 SINGLE_PRESS_TYPE = "single_press_type" 119 120 121class ThermostatProps(Enum): 122 APP_VERSION = "app_version" 123 IOT_STATE = "iot_state" # Connection state: connected, disconnected 124 SETUP_STATE = "setup_state" 125 CURRENT_SCENARIO = "current_scenario" # home, away 126 PROTECT_TIME = "protect_time" 127 COOL_SP = "cool_sp" # Cool stop point 128 EMHEAT = "emheat" 129 TIME2TEMP_VAL = "time2temp_val" 130 SAVE_COMFORT_BALANCE = "save_comfort_balance" # savings, comfort, or balance value 131 QUERY_SCHEDULE = "query_schedule" 132 WORKING_STATE = "working_state" # idle, etc. 133 WIRING_LOGIC_ID = "wiring_logic_id" 134 W_CITY_ID = "w_city_id" 135 FAN_MODE = "fan_mode" # auto, on, off 136 TEMPERATURE = "temperature" # current temp 137 HUMIDITY = "humidity" # current humidity 138 KID_LOCK = "kid_lock" 139 CALIBRATE_HUMIDITY = "calibrate_humidity" 140 HEAT_SP = "heat_sp" # heat stop point 141 CALIBRATE_TEMPERATURE = "calibrate_temperature" 142 MODE_SYS = "mode_sys" # auto, heat, cool 143 W_LAT = "w_lat" 144 CONFIG_SCENARIO = "config_scenario" 145 FANCIRC_TIME = "fancirc_time" 146 W_LON = "w_lon" 147 DEV_HOLD = "dev_hold" 148 TEMP_UNIT = "temp_unit" 149 ASW_HOLD = "asw_hold" 150 151 152class ResponseCodes(Enum): 153 SUCCESS = "1" 154 PARAMETER_ERROR = "1001" 155 ACCESS_TOKEN_ERROR = "2001" 156 DEVICE_OFFLINE = '3019' 157 158 159class ResponseCodesLock(Enum): 160 SUCCESS = 0 161 162 163class File: 164 file_id: str 165 type: Union[int, str] 166 url: str 167 status: int 168 en_algorithm: int 169 en_password: str 170 is_ai: int 171 ai_tag_list: List[Any] 172 ai_url: str 173 file_params: Dict[Any, Any] 174 175 def __init__(self, dictionary: Dict[Any, Any]): 176 for k, v in dictionary.items(): 177 setattr(self, k, v) 178 179 if self.type == 1: 180 self.type = "Image" 181 else: 182 self.type = "Video" 183 184 185class Event: 186 event_id: str 187 device_mac: str 188 device_model: str 189 event_category: int 190 event_value: str 191 event_ts: int 192 event_ack_result: int 193 is_feedback_correct: int 194 is_feedback_face: int 195 is_feedback_person: int 196 file_list: List[Dict[Any, Any]] 197 event_params: Dict[Any, Any] 198 recognized_instance_list: List[Any] 199 tag_list: List[Any] 200 read_state: int 201 202 def __init__(self, dictionary: Dict[Any, Any]): 203 for k, v in dictionary.items(): 204 setattr(self, k, v) 205 206 207class HMSStatus(Enum): 208 DISARMED = 'disarmed' 209 HOME = 'home' 210 AWAY = 'away' 211 212 213class DeviceMgmtToggleType: 214 def __init__(self, pageId, toggleId): 215 self.pageId = pageId 216 self.toggleId = toggleId 217 218 219class DeviceMgmtToggleProps(Enum): 220 EVENT_RECORDING_TOGGLE = DeviceMgmtToggleType("cam_event_recording", "ge.motion_detect_recording") 221 NOTIFICATION_TOGGLE = DeviceMgmtToggleType("cam_device_notify", "ge.push_switch")
class
Group:
11class Group: 12 group_id: str 13 group_name: str 14 15 def __init__(self, dictionary: Dict[Any, Any]): 16 for k, v in dictionary.items(): 17 setattr(self, k, v) 18 19 def __repr__(self) -> str: 20 return "<Group: {}, {}>".format(self.group_id, self.group_name)
class
DeviceTypes(enum.Enum):
23class DeviceTypes(Enum): 24 LIGHT = "Light" 25 PLUG = "Plug" 26 OUTDOOR_PLUG = "OutdoorPlug" 27 MESH_LIGHT = "MeshLight" 28 CAMERA = "Camera" 29 CHIME_SENSOR = "ChimeSensor" 30 CONTACT_SENSOR = "ContactSensor" 31 MOTION_SENSOR = "MotionSensor" 32 LEAK_SENSOR = "LeakSensor" 33 WRIST = "Wrist" 34 BASE_STATION = "BaseStation" 35 SCALE = "WyzeScale" 36 LOCK = "Lock" 37 GATEWAY = "gateway" 38 COMMON = "Common" 39 VACUUM = "JA_RO2" 40 HEADPHONES = "JA.SC" 41 THERMOSTAT = "Thermostat" 42 GATEWAY_V2 = "GateWay" 43 UNKNOWN = "Unknown" 44 SENSE_V2_GATEWAY = "S1Gateway" 45 KEYPAD = "Keypad" 46 LIGHTSTRIP = "LightStrip"
LIGHT =
<DeviceTypes.LIGHT: 'Light'>
PLUG =
<DeviceTypes.PLUG: 'Plug'>
OUTDOOR_PLUG =
<DeviceTypes.OUTDOOR_PLUG: 'OutdoorPlug'>
MESH_LIGHT =
<DeviceTypes.MESH_LIGHT: 'MeshLight'>
CAMERA =
<DeviceTypes.CAMERA: 'Camera'>
CHIME_SENSOR =
<DeviceTypes.CHIME_SENSOR: 'ChimeSensor'>
CONTACT_SENSOR =
<DeviceTypes.CONTACT_SENSOR: 'ContactSensor'>
MOTION_SENSOR =
<DeviceTypes.MOTION_SENSOR: 'MotionSensor'>
LEAK_SENSOR =
<DeviceTypes.LEAK_SENSOR: 'LeakSensor'>
WRIST =
<DeviceTypes.WRIST: 'Wrist'>
BASE_STATION =
<DeviceTypes.BASE_STATION: 'BaseStation'>
SCALE =
<DeviceTypes.SCALE: 'WyzeScale'>
LOCK =
<DeviceTypes.LOCK: 'Lock'>
GATEWAY =
<DeviceTypes.GATEWAY: 'gateway'>
COMMON =
<DeviceTypes.COMMON: 'Common'>
VACUUM =
<DeviceTypes.VACUUM: 'JA_RO2'>
HEADPHONES =
<DeviceTypes.HEADPHONES: 'JA.SC'>
THERMOSTAT =
<DeviceTypes.THERMOSTAT: 'Thermostat'>
GATEWAY_V2 =
<DeviceTypes.GATEWAY_V2: 'GateWay'>
UNKNOWN =
<DeviceTypes.UNKNOWN: 'Unknown'>
SENSE_V2_GATEWAY =
<DeviceTypes.SENSE_V2_GATEWAY: 'S1Gateway'>
KEYPAD =
<DeviceTypes.KEYPAD: 'Keypad'>
LIGHTSTRIP =
<DeviceTypes.LIGHTSTRIP: 'LightStrip'>
class
Device:
49class Device: 50 product_type: str 51 product_model: str 52 mac: str 53 nickname: str 54 device_params: Dict[str, Any] 55 raw_dict: Dict[str, Any] 56 callback_function = None 57 58 def __init__(self, dictionary: Dict[Any, Any]): 59 self.available = False 60 61 self.raw_dict = dictionary 62 for k, v in dictionary.items(): 63 setattr(self, k, v) 64 65 @property 66 def type(self) -> DeviceTypes: 67 try: 68 return DeviceTypes(self.product_type) 69 except ValueError: 70 return DeviceTypes.UNKNOWN 71 72 def __repr__(self) -> str: 73 return "<Device: {}, {}>".format(DeviceTypes(self.product_type), self.mac)
76class Sensor(Device): 77 def __init__(self, dictionary: Dict[Any, Any]): 78 super().__init__(dictionary) 79 80 @property 81 def activity_detected(self) -> int: 82 if self.type is DeviceTypes.CONTACT_SENSOR: 83 return int(self.device_params['open_close_state']) 84 elif self.type is DeviceTypes.MOTION_SENSOR: 85 return int(self.device_params['motion_state']) 86 else: 87 raise AssertionError("Device must be of type CONTACT_SENSOR or MOTION_SENSOR") 88 89 @property 90 def is_low_battery(self) -> int: 91 return int(self.device_params['is_low_battery'])
activity_detected: int
80 @property 81 def activity_detected(self) -> int: 82 if self.type is DeviceTypes.CONTACT_SENSOR: 83 return int(self.device_params['open_close_state']) 84 elif self.type is DeviceTypes.MOTION_SENSOR: 85 return int(self.device_params['motion_state']) 86 else: 87 raise AssertionError("Device must be of type CONTACT_SENSOR or MOTION_SENSOR")
Inherited Members
class
PropertyIDs(enum.Enum):
94class PropertyIDs(Enum): 95 NOTIFICATION = "P1" 96 ON = "P3" 97 AVAILABLE = "P5" 98 BRIGHTNESS = "P1501" # From 0-100 99 COLOR_TEMP = "P1502" # In Kelvin 100 COLOR = "P1507" # As a hex string RrGgBb 101 COLOR_MODE = "P1508" # 1 = Basic Color, 2 = White, 3 = Effect Mode 102 LIGHTSTRIP_EFFECTS = "P1522" 103 LIGHTSTRIP_MUSIC_MODE = "P1535" 104 DOOR_OPEN = "P2001" # 0 if the door is closed 105 CONTACT_STATE = "P1301" 106 MOTION_STATE = "P1302" 107 CAMERA_SIREN = "P1049" 108 ACCESSORY = "P1056" # Is state for camera accessories, like garage doors, light sockets, and floodlights. 109 SUN_MATCH = "P1528" 110 MOTION_DETECTION = "P1047" # Current Motion Detection State of the Camera 111 MOTION_DETECTION_TOGGLE = "P1001" # This toggles Camera Motion Detection On/Off 112 WCO_MOTION_DETECTION = "P1029" # Wyze cam outdoor requires both P1047 and P1029 to be set. P1029 is set via set_property_list
NOTIFICATION =
<PropertyIDs.NOTIFICATION: 'P1'>
ON =
<PropertyIDs.ON: 'P3'>
AVAILABLE =
<PropertyIDs.AVAILABLE: 'P5'>
BRIGHTNESS =
<PropertyIDs.BRIGHTNESS: 'P1501'>
COLOR_TEMP =
<PropertyIDs.COLOR_TEMP: 'P1502'>
COLOR =
<PropertyIDs.COLOR: 'P1507'>
COLOR_MODE =
<PropertyIDs.COLOR_MODE: 'P1508'>
LIGHTSTRIP_EFFECTS =
<PropertyIDs.LIGHTSTRIP_EFFECTS: 'P1522'>
LIGHTSTRIP_MUSIC_MODE =
<PropertyIDs.LIGHTSTRIP_MUSIC_MODE: 'P1535'>
DOOR_OPEN =
<PropertyIDs.DOOR_OPEN: 'P2001'>
CONTACT_STATE =
<PropertyIDs.CONTACT_STATE: 'P1301'>
MOTION_STATE =
<PropertyIDs.MOTION_STATE: 'P1302'>
CAMERA_SIREN =
<PropertyIDs.CAMERA_SIREN: 'P1049'>
ACCESSORY =
<PropertyIDs.ACCESSORY: 'P1056'>
SUN_MATCH =
<PropertyIDs.SUN_MATCH: 'P1528'>
MOTION_DETECTION =
<PropertyIDs.MOTION_DETECTION: 'P1047'>
MOTION_DETECTION_TOGGLE =
<PropertyIDs.MOTION_DETECTION_TOGGLE: 'P1001'>
WCO_MOTION_DETECTION =
<PropertyIDs.WCO_MOTION_DETECTION: 'P1029'>
class
WallSwitchProps(enum.Enum):
115class WallSwitchProps(Enum): 116 IOT_STATE = "iot_state" # Connection state: connected, disconnected 117 SWITCH_POWER = "switch-power" 118 SWITCH_IOT = "switch-iot" 119 SINGLE_PRESS_TYPE = "single_press_type"
IOT_STATE =
<WallSwitchProps.IOT_STATE: 'iot_state'>
SWITCH_POWER =
<WallSwitchProps.SWITCH_POWER: 'switch-power'>
SWITCH_IOT =
<WallSwitchProps.SWITCH_IOT: 'switch-iot'>
SINGLE_PRESS_TYPE =
<WallSwitchProps.SINGLE_PRESS_TYPE: 'single_press_type'>
class
ThermostatProps(enum.Enum):
122class ThermostatProps(Enum): 123 APP_VERSION = "app_version" 124 IOT_STATE = "iot_state" # Connection state: connected, disconnected 125 SETUP_STATE = "setup_state" 126 CURRENT_SCENARIO = "current_scenario" # home, away 127 PROTECT_TIME = "protect_time" 128 COOL_SP = "cool_sp" # Cool stop point 129 EMHEAT = "emheat" 130 TIME2TEMP_VAL = "time2temp_val" 131 SAVE_COMFORT_BALANCE = "save_comfort_balance" # savings, comfort, or balance value 132 QUERY_SCHEDULE = "query_schedule" 133 WORKING_STATE = "working_state" # idle, etc. 134 WIRING_LOGIC_ID = "wiring_logic_id" 135 W_CITY_ID = "w_city_id" 136 FAN_MODE = "fan_mode" # auto, on, off 137 TEMPERATURE = "temperature" # current temp 138 HUMIDITY = "humidity" # current humidity 139 KID_LOCK = "kid_lock" 140 CALIBRATE_HUMIDITY = "calibrate_humidity" 141 HEAT_SP = "heat_sp" # heat stop point 142 CALIBRATE_TEMPERATURE = "calibrate_temperature" 143 MODE_SYS = "mode_sys" # auto, heat, cool 144 W_LAT = "w_lat" 145 CONFIG_SCENARIO = "config_scenario" 146 FANCIRC_TIME = "fancirc_time" 147 W_LON = "w_lon" 148 DEV_HOLD = "dev_hold" 149 TEMP_UNIT = "temp_unit" 150 ASW_HOLD = "asw_hold"
APP_VERSION =
<ThermostatProps.APP_VERSION: 'app_version'>
IOT_STATE =
<ThermostatProps.IOT_STATE: 'iot_state'>
SETUP_STATE =
<ThermostatProps.SETUP_STATE: 'setup_state'>
CURRENT_SCENARIO =
<ThermostatProps.CURRENT_SCENARIO: 'current_scenario'>
PROTECT_TIME =
<ThermostatProps.PROTECT_TIME: 'protect_time'>
COOL_SP =
<ThermostatProps.COOL_SP: 'cool_sp'>
EMHEAT =
<ThermostatProps.EMHEAT: 'emheat'>
TIME2TEMP_VAL =
<ThermostatProps.TIME2TEMP_VAL: 'time2temp_val'>
SAVE_COMFORT_BALANCE =
<ThermostatProps.SAVE_COMFORT_BALANCE: 'save_comfort_balance'>
QUERY_SCHEDULE =
<ThermostatProps.QUERY_SCHEDULE: 'query_schedule'>
WORKING_STATE =
<ThermostatProps.WORKING_STATE: 'working_state'>
WIRING_LOGIC_ID =
<ThermostatProps.WIRING_LOGIC_ID: 'wiring_logic_id'>
W_CITY_ID =
<ThermostatProps.W_CITY_ID: 'w_city_id'>
FAN_MODE =
<ThermostatProps.FAN_MODE: 'fan_mode'>
TEMPERATURE =
<ThermostatProps.TEMPERATURE: 'temperature'>
HUMIDITY =
<ThermostatProps.HUMIDITY: 'humidity'>
KID_LOCK =
<ThermostatProps.KID_LOCK: 'kid_lock'>
CALIBRATE_HUMIDITY =
<ThermostatProps.CALIBRATE_HUMIDITY: 'calibrate_humidity'>
HEAT_SP =
<ThermostatProps.HEAT_SP: 'heat_sp'>
CALIBRATE_TEMPERATURE =
<ThermostatProps.CALIBRATE_TEMPERATURE: 'calibrate_temperature'>
MODE_SYS =
<ThermostatProps.MODE_SYS: 'mode_sys'>
W_LAT =
<ThermostatProps.W_LAT: 'w_lat'>
CONFIG_SCENARIO =
<ThermostatProps.CONFIG_SCENARIO: 'config_scenario'>
FANCIRC_TIME =
<ThermostatProps.FANCIRC_TIME: 'fancirc_time'>
W_LON =
<ThermostatProps.W_LON: 'w_lon'>
DEV_HOLD =
<ThermostatProps.DEV_HOLD: 'dev_hold'>
TEMP_UNIT =
<ThermostatProps.TEMP_UNIT: 'temp_unit'>
ASW_HOLD =
<ThermostatProps.ASW_HOLD: 'asw_hold'>
class
ResponseCodes(enum.Enum):
153class ResponseCodes(Enum): 154 SUCCESS = "1" 155 PARAMETER_ERROR = "1001" 156 ACCESS_TOKEN_ERROR = "2001" 157 DEVICE_OFFLINE = '3019'
SUCCESS =
<ResponseCodes.SUCCESS: '1'>
PARAMETER_ERROR =
<ResponseCodes.PARAMETER_ERROR: '1001'>
ACCESS_TOKEN_ERROR =
<ResponseCodes.ACCESS_TOKEN_ERROR: '2001'>
DEVICE_OFFLINE =
<ResponseCodes.DEVICE_OFFLINE: '3019'>
class
ResponseCodesLock(enum.Enum):
SUCCESS =
<ResponseCodesLock.SUCCESS: 0>
class
File:
164class File: 165 file_id: str 166 type: Union[int, str] 167 url: str 168 status: int 169 en_algorithm: int 170 en_password: str 171 is_ai: int 172 ai_tag_list: List[Any] 173 ai_url: str 174 file_params: Dict[Any, Any] 175 176 def __init__(self, dictionary: Dict[Any, Any]): 177 for k, v in dictionary.items(): 178 setattr(self, k, v) 179 180 if self.type == 1: 181 self.type = "Image" 182 else: 183 self.type = "Video"
class
Event:
186class Event: 187 event_id: str 188 device_mac: str 189 device_model: str 190 event_category: int 191 event_value: str 192 event_ts: int 193 event_ack_result: int 194 is_feedback_correct: int 195 is_feedback_face: int 196 is_feedback_person: int 197 file_list: List[Dict[Any, Any]] 198 event_params: Dict[Any, Any] 199 recognized_instance_list: List[Any] 200 tag_list: List[Any] 201 read_state: int 202 203 def __init__(self, dictionary: Dict[Any, Any]): 204 for k, v in dictionary.items(): 205 setattr(self, k, v)
class
HMSStatus(enum.Enum):
DISARMED =
<HMSStatus.DISARMED: 'disarmed'>
HOME =
<HMSStatus.HOME: 'home'>
AWAY =
<HMSStatus.AWAY: 'away'>
class
DeviceMgmtToggleType:
214class DeviceMgmtToggleType: 215 def __init__(self, pageId, toggleId): 216 self.pageId = pageId 217 self.toggleId = toggleId
class
DeviceMgmtToggleProps(enum.Enum):
220class DeviceMgmtToggleProps(Enum): 221 EVENT_RECORDING_TOGGLE = DeviceMgmtToggleType("cam_event_recording", "ge.motion_detect_recording") 222 NOTIFICATION_TOGGLE = DeviceMgmtToggleType("cam_device_notify", "ge.push_switch")
EVENT_RECORDING_TOGGLE =
<DeviceMgmtToggleProps.EVENT_RECORDING_TOGGLE: <DeviceMgmtToggleType object>>
NOTIFICATION_TOGGLE =
<DeviceMgmtToggleProps.NOTIFICATION_TOGGLE: <DeviceMgmtToggleType object>>