Пример #1
0
 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)
Пример #2
0
 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),
     }
Пример #3
0
    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)
Пример #4
0
 def remaining_time(cls) -> PropDef:
     return PropDef("P1505", int)
Пример #5
0
 def current_scenario(cls) -> PropDef:
     return PropDef("current_scenario", str)
Пример #6
0
 def push_notifications_enabled(cls) -> PropDef:
     return PropDef("P1", bool, int, [0, 1])
Пример #7
0
 def online_state(cls) -> PropDef:
     return PropDef("P5", bool, int, [0, 1])
Пример #8
0
 def status_light(cls) -> PropDef:
     return PropDef("P13", bool)
Пример #9
0
 def rssi(cls) -> PropDef:
     return PropDef("P1612", int)
Пример #10
0
 def time_to_temp(cls) -> PropDef:
     return PropDef("time2temp_val", int)  # in minutes
Пример #11
0
 def temperature_unit(cls) -> PropDef:
     return PropDef("temp_unit", str, acceptable_values=['F', 'C'])
Пример #12
0
 def temperature(cls) -> PropDef:
     return PropDef("temperature", float)
Пример #13
0
 def color_temp_mesh(cls) -> PropDef:
     return PropDef("P1502", int, acceptable_values=range(1800, 6500 + 1))
Пример #14
0
 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),
     }
Пример #15
0
 def delay_off(cls) -> PropDef:
     return PropDef("P1510", bool, int, [0, 1])
Пример #16
0
 def control_light(cls) -> PropDef:
     return PropDef("P1508", bool, int, [0, 1])
Пример #17
0
 def working_state(cls) -> PropDef:
     return PropDef("working_state", str)
Пример #18
0
 def humidity(cls) -> PropDef:
     return PropDef("humidity", int)
Пример #19
0
 def auto_switch(cls) -> PropDef:
     return PropDef("auto_switch_mode", int)
Пример #20
0
 def fan_mode(cls) -> PropDef:
     return PropDef("fan_mode", str)
Пример #21
0
 def unit(cls) -> PropDef:
     return PropDef('unit', str, acceptable_values=['kg', 'lb'])
Пример #22
0
 def system_mode(cls) -> PropDef:
     return PropDef("mode_sys", str)
Пример #23
0
 def away_mode(cls) -> PropDef:
     return PropDef("P1614", bool)
Пример #24
0
 def locked(cls) -> PropDef:
     return PropDef("kid_lock", bool, str, ['0', '1'])
Пример #25
0
 def photosensitive_switch(cls) -> PropDef:
     return PropDef("photosensitive_switch", bool)
Пример #26
0
 def brightness(cls) -> PropDef:
     return PropDef("P1501", int, acceptable_values=range(0, 100 + 1))
Пример #27
0
 def power_state(cls) -> PropDef:
     return PropDef("P3", bool, int, [0, 1])
Пример #28
0
 def cooling_setpoint(cls) -> PropDef:
     return PropDef("cool_sp", int, str)
Пример #29
0
 def heating_setpoint(cls) -> PropDef:
     return PropDef("heat_sp", int, str)
Пример #30
0
 def color(cls) -> PropDef:
     return PropDef("P1507", str)