Пример #1
0
    def __init__(
        self,
        mqtt_client: MqttClient,
        device_id: str,
        name: str,
        status_path: str,
        control_path: str,
        description: typing.Optional[str] = None,
        room=None,
    ):
        self.client = mqtt_client
        self.onoff = OnOff(
            change_value=self.change_onoff,
            retrievable=True,
            reportable=True,
        )

        self.status_path = status_path
        self.control_path = control_path
        self.client.subscribe(self.status_path, self.on_onoff_changed)

        super().__init__(
            device_id=device_id,
            capabilities=[self.onoff],
            device_name=name,
            description=description,
            room=room,
            manufacturer='torkve',
            model='WB',
        )
    def __init__(
        self,
        mqtt_client: MqttClient,
        device_id: str,
        name: str,
        brightness_status_path: str,
        brightness_control_path: str,
        onoff_status_path: str,
        onoff_control_path: str,
        range_low: int,
        range_high: int,
        description: typing.Optional[str] = None,
        room=None,
    ):
        self.client = mqtt_client
        self.onoff = OnOff(
            change_value=self.change_onoff,
            retrievable=True,
            reportable=True,
        )
        self.level = Range(
            change_value=self.change_level,
            retrievable=True,
            reportable=True,
            instance=Range.Instance.Brightness,
            unit=Range.Unit.Percent,
            min_value=0.,
            max_value=100.,
            precision=1. if (range_high - range_low) < 500 else 0.1,
        )

        self.range_low = range_low
        self.range_high = range_high
        self.brightness_status_path = brightness_status_path
        self.brightness_control_path = brightness_control_path
        self.onoff_status_path = onoff_status_path
        self.onoff_control_path = onoff_control_path
        self.client.subscribe(self.brightness_status_path,
                              self.on_level_changed)
        self.client.subscribe(self.onoff_status_path, self.on_onoff_changed)

        super().__init__(
            device_id=device_id,
            capabilities=[self.onoff, self.level],
            device_name=name,
            description=description,
            room=room,
            manufacturer='torkve',
            model='WB',
        )
Пример #3
0
    def __init__(
        self,
        mqtt_client: MqttClient,
        device_id: str,
        name: str,
        device_path: str,
        description: typing.Optional[str] = None,
        room=None,
    ):
        self.client = mqtt_client
        self.onoff_status_path = f'{device_path}/OnOff'
        self.onoff_control_path = f'{device_path}/OnOff/on'
        self.mode_status_path = f'{device_path}/Mode'
        self.mode_control_path = f'{device_path}/Mode/on'
        self.setpoint_status_path = f'{device_path}/Setpoint'
        self.setpoint_control_path = f'{device_path}/Setpoint/on'
        self.fanspeed_status_path = f'{device_path}/Fanspeed'
        self.fanspeed_control_path = f'{device_path}/Fanspeed/on'
        self.louvre_status_path = f'{device_path}/Louvre'
        self.louvre_control_path = f'{device_path}/Louvre/on'
        self.temperature_path = f'{device_path}/Return Air Temperature'

        self.onoff = OnOff(
            change_value=self.change_onoff,
            retrievable=True,
            reportable=True,
        )

        self.setpoint = Range(
            instance=Range.Instance.Temperature,
            unit=Range.Unit.TemperatureCelsius,
            min_value=18.,
            max_value=32.,
            precision=0.5,
            retrievable=True,
            reportable=True,
            change_value=self.change_setpoint,
        )

        self.fanspeed = Mode(
            instance=Mode.Instance.FanSpeed,
            modes=[Mode.WorkMode.Low, Mode.WorkMode.High, Mode.WorkMode.Turbo],
            change_value=self.change_fanspeed,
            retrievable=True,
            reportable=True,
        )

        self.mode = Mode(
            instance=Mode.Instance.Thermostat,
            modes=[
                Mode.WorkMode.Auto,
                Mode.WorkMode.Heat,
                Mode.WorkMode.FanOnly,
                Mode.WorkMode.Cool,
                Mode.WorkMode.Dry,
            ],
            change_value=self.change_mode,
            retrievable=True,
            reportable=True,
        )

        self.louvre = Mode(
            instance=Mode.Instance.Swing,
            modes=[
                Mode.WorkMode.Auto,
                Mode.WorkMode.One,
                Mode.WorkMode.Two,
                Mode.WorkMode.Three,
                Mode.WorkMode.Four,
                Mode.WorkMode.Five,
            ],
            change_value=self.change_louvre,
            retrievable=True,
            reportable=True,
        )

        self.temperature = Temperature(unit=Temperature.Unit.Celsius,
                                       reportable=True)

        self.client.subscribe(self.onoff_status_path, self.on_onoff_changed)
        self.client.subscribe(self.setpoint_status_path,
                              self.on_setpoint_changed)
        self.client.subscribe(self.mode_status_path, self.on_mode_changed)
        self.client.subscribe(self.louvre_status_path, self.on_louvre_changed)
        self.client.subscribe(self.fanspeed_status_path,
                              self.on_fanspeed_changed)
        self.client.subscribe(self.temperature_path,
                              self.on_temperature_changed)

        super().__init__(
            device_id=device_id,
            capabilities=[
                self.onoff, self.setpoint, self.fanspeed, self.mode,
                self.louvre
            ],
            properties=[self.temperature],
            device_name=name,
            description=description,
            room=room,
            manufacturer='torkve',
            model='WB',
        )
Пример #4
0
 def __init__(
     self,
     mqtt_client: MqttClient,
     device_id: str,
     name: str,
     direction_status_path: str,
     motor_status_path: str,
     direction_control_path: str,
     motor_control_path: str,
     action_time_seconds: int,
     description: typing.Optional[str] = None,
     room=None,
 ):
     self.client = mqtt_client
     self.updown = OnOff(
         change_value=self.change_updown,
         retrievable=False,
         split=True,
     )
     self.direction = Mode(
         instance=Mode.Instance.Swing,
         modes=[Mode.WorkMode.High, Mode.WorkMode.Low],
         retrievable=True,
         reportable=True,
         change_value=self.change_direction,
     )
     self.motor = Toggle(
         instance=Toggle.Instance.Oscillation,
         retrievable=True,
         reportable=True,
         change_value=self.change_motor,
     )
     self.partial_open = Range(
         instance=Range.Instance.Open,
         unit=Range.Unit.Percent,
         random_access=False,
         retrievable=False,
         min_value=0.,
         max_value=100.,
         precision=5.,
         change_value=self.change_partial_open,
     )
     self.direction_status_path = direction_status_path
     self.motor_status_path = motor_status_path
     self.direction_control_path = direction_control_path
     self.motor_control_path = motor_control_path
     self.action_times_seconds = action_time_seconds
     self.client.subscribe(self.direction_status_path,
                           self.on_direction_changed)
     self.client.subscribe(self.motor_status_path, self.on_motor_changed)
     self.task: typing.Optional[asyncio.Task] = None
     super().__init__(
         device_id=device_id,
         capabilities=[
             self.updown, self.partial_open, self.direction, self.motor
         ],
         device_name=name,
         description=description,
         room=room,
         manufacturer='torkve',
         model='WB',
     )
Пример #5
0
    def __init__(
        self,
        mqtt_client: MqttClient,
        device_id: str,
        name: str,
        warm_status_path: str,
        warm_control_path: str,
        cold_status_path: str,
        cold_control_path: str,
        warm_temperature: int,
        cold_temperature: int,
        range_low: int,
        range_high: int,
        description: typing.Optional[str] = None,
        room=None,
    ):
        self.client = mqtt_client
        self.onoff = OnOff(
            change_value=self.change_onoff,
            retrievable=True,
            reportable=True,
        )
        self.last_brightness_val = 100.
        self.last_temperature_val = (
            4500 if warm_temperature <= 4500 <= cold_temperature else
            (warm_temperature + cold_temperature) // 2)

        self.level = Range(
            change_value=self.change_level,
            retrievable=True,
            reportable=True,
            instance=Range.Instance.Brightness,
            unit=Range.Unit.Percent,
            min_value=0.,
            max_value=100.,
            precision=1. if (range_high - range_low) < 500 else 0.1,
        )
        self.temperature = ColorSetting(
            temperature=ColorSetting.Temperature(
                min=warm_temperature,
                max=cold_temperature,
                value=self.last_temperature_val,
            ),
            retrievable=True,
            reportable=True,
            change_value=self.change_temperature,
        )

        self.warm_value = range_low
        self.cold_value = range_low

        self.range_low = range_low
        self.range_high = range_high
        self.warm_status_path = warm_status_path
        self.warm_control_path = warm_control_path
        self.warm_temperature = warm_temperature
        self.cold_status_path = cold_status_path
        self.cold_control_path = cold_control_path
        self.cold_temperature = cold_temperature

        self.client.subscribe(self.warm_status_path, self.on_data_changed)
        self.client.subscribe(self.cold_status_path, self.on_data_changed)

        super().__init__(
            device_id=device_id,
            capabilities=[self.onoff, self.level, self.temperature],
            device_name=name,
            description=description,
            room=room,
            manufacturer='torkve',
            model='WB',
        )