def __init__(self, *, event_list: Optional[Sequence[dict]] = None, **others: dict): super().__init__(type=self.type, **others) self.switch_state = super()._extract_property( DeviceProps.power_state(), others) self.motion_state = DeviceProp( definition=PropDef("", bool, bool), value=False ) # TODO: add support for parsing recent events to see if there's current motion self._temperature = super()._extract_attribute('temperature', others) self._humidity = super()._extract_attribute('humidity', others) self._voltage = super()._extract_property(CameraProps.voltage(), others) self._supports_audio_alarm = super()._extract_property( CameraProps.suppprts_audio_alarm(), others) self._supports_co_alarm = super()._extract_property( CameraProps.suppprts_co_alarm(), others) self._supports_motion_alarm = super()._extract_property( CameraProps.suppprts_motion_alarm(), others) self._suppprts_smoke_alarm = super()._extract_property( CameraProps.suppprts_smoke_alarm(), others) if event_list is not None: self.latest_events = event_list show_unknown_key_warning(self, others)
def device_info_props(cls) -> dict[str, PropDef]: return { "auto_switch_mode": ThermostatProps.auto_switch(), "setup_is_have_cadapter": PropDef("setup_is_have_cadapter", str), "setup_personalization_state": PropDef("setup_personalization_state", str), "setup_step": PropDef("setup_step", str), "setup_test_state": PropDef("setup_test_state", str), "setup_wires": PropDef("setup_wires", dict), "plugin_version": PropDef("plugin_version", str), "terminal_type": PropDef("terminal_type", str), }
def _extract_property(self, prop_def: Union[str, PropDef], others: Union[dict, Sequence[dict]]) -> DeviceProp: if isinstance(prop_def, str): prop_def = PropDef(pid=prop_def) if isinstance(others, dict): if 'data' in others and 'property_list' in others['data']: self.logger.debug("found non-empty data property_list") return self._extract_property(prop_def=prop_def, others=others['data']) if 'props' in others and others['props']: self.logger.debug("found non-empty props") return self._extract_property(prop_def=prop_def, others=others['props']) if 'property_list' in others and others['property_list']: self.logger.debug("found non-empty property_list") return self._extract_property(prop_def=prop_def, others=others['property_list']) if 'device_params' in others and others['device_params']: self.logger.debug("found non-empty device_params") return self._extract_property(prop_def=prop_def, others=others['device_params']) self.logger.debug( f"extracting property {prop_def.pid} from dict {others}") for key, value in others.items(): self.logger.debug(f"key: {key}, value: {value}") if key == prop_def.pid: self.logger.debug( f"returning new DeviceProp with value {value}") return DeviceProp(definition=prop_def, value=value) else: self.logger.debug( f"extracting property {prop_def.pid} from {others.__class__} {others}" ) for value in others: self.logger.debug(f"value {value}") if "pid" in value and prop_def.pid == value["pid"]: self.logger.debug(f"returning new DeviceProp with {value}") return DeviceProp(definition=prop_def, **value)
def remaining_time(cls) -> PropDef: return PropDef("P1505", int)
def current_scenario(cls) -> PropDef: return PropDef("current_scenario", str)
def push_notifications_enabled(cls) -> PropDef: return PropDef("P1", bool, int, [0, 1])
def online_state(cls) -> PropDef: return PropDef("P5", bool, int, [0, 1])
def status_light(cls) -> PropDef: return PropDef("P13", bool)
def rssi(cls) -> PropDef: return PropDef("P1612", int)
def time_to_temp(cls) -> PropDef: return PropDef("time2temp_val", int) # in minutes
def temperature_unit(cls) -> PropDef: return PropDef("temp_unit", str, acceptable_values=['F', 'C'])
def temperature(cls) -> PropDef: return PropDef("temperature", float)
def color_temp_mesh(cls) -> PropDef: return PropDef("P1502", int, acceptable_values=range(1800, 6500 + 1))
def props(cls) -> dict[str, PropDef]: return { "trigger_off_val": PropDef("trigger_off_val", int), "emheat": PropDef("emheat", int), "temperature": ThermostatProps.temperature(), "humidity": ThermostatProps.humidity(), "time2temp_val": ThermostatProps.time_to_temp(), "protect_time": PropDef("protect_time", str), "system_mode": ThermostatProps.system_mode(), "heating_setpoint": ThermostatProps.heating_setpoint(), "cooling_setpoint": ThermostatProps.cooling_setpoint(), "current_scenario": ThermostatProps.current_scenario(), "config_scenario": PropDef("config_scenario", dict), "temp_unit": ThermostatProps.temperature_unit(), "fan_mode": ThermostatProps.fan_mode(), "iot_state": PropDef("iot_state", str), "w_city_id": PropDef("w_city_id", int), "w_lat": PropDef("w_lat", int), "w_lon": PropDef("w_lon", int), "working_state": ThermostatProps.working_state(), "device_hold": PropDef("dev_hold", int), "device_hold_time": PropDef("dev_holdtime", int), "asw_hold": PropDef("asw_hold", int), "app_version": PropDef("app_version", int), "setup_state": PropDef("setup_state", int), "wiring_logic_id": PropDef("wiring_logic_id", int), "save_comfort_balance": PropDef("save_comfort_balance", int), "locked": ThermostatProps.locked(), "calibrate_humidity": PropDef("calibrate_humidity", str), "calibrate_temperature": PropDef("calibrate_temperature", str), "fancirc_time": PropDef("fancirc_time", str), "query_schedule": PropDef("query_schedule", str), }
def delay_off(cls) -> PropDef: return PropDef("P1510", bool, int, [0, 1])
def control_light(cls) -> PropDef: return PropDef("P1508", bool, int, [0, 1])
def working_state(cls) -> PropDef: return PropDef("working_state", str)
def humidity(cls) -> PropDef: return PropDef("humidity", int)
def auto_switch(cls) -> PropDef: return PropDef("auto_switch_mode", int)
def fan_mode(cls) -> PropDef: return PropDef("fan_mode", str)
def unit(cls) -> PropDef: return PropDef('unit', str, acceptable_values=['kg', 'lb'])
def system_mode(cls) -> PropDef: return PropDef("mode_sys", str)
def away_mode(cls) -> PropDef: return PropDef("P1614", bool)
def locked(cls) -> PropDef: return PropDef("kid_lock", bool, str, ['0', '1'])
def photosensitive_switch(cls) -> PropDef: return PropDef("photosensitive_switch", bool)
def brightness(cls) -> PropDef: return PropDef("P1501", int, acceptable_values=range(0, 100 + 1))
def power_state(cls) -> PropDef: return PropDef("P3", bool, int, [0, 1])
def cooling_setpoint(cls) -> PropDef: return PropDef("cool_sp", int, str)
def heating_setpoint(cls) -> PropDef: return PropDef("heat_sp", int, str)
def color(cls) -> PropDef: return PropDef("P1507", str)