Skip to content
This repository has been archived by the owner on Oct 7, 2021. It is now read-only.

maintenance to use discovery update #4

Merged
merged 3 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions custom_components/tuya_custom/tuyaha/devices/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,27 @@ def max_humidity(self):

def set_temperature(self, temperature):
"""Set new target temperature."""
self.api.device_control(
self.obj_id, "temperatureSet", {"value": float(temperature)}
)
if self._control_device("temperatureSet", {"value": float(temperature)}):
self._update_data("temperature", temperature)

def set_humidity(self, humidity):
"""Set new target humidity."""
raise NotImplementedError()

def set_fan_mode(self, fan_mode):
"""Set new target fan mode."""
self.api.device_control(self.obj_id, "windSpeedSet", {"value": fan_mode})
if self._control_device("windSpeedSet", {"value": fan_mode}):
fanList = self.fan_list()
if fan_mode in fanList:
val = str(fanList.index(fan_mode) + 1)
else:
val = fan_mode
self._update_data("windspeed", val)

ollo69 marked this conversation as resolved.
Show resolved Hide resolved
def set_operation_mode(self, operation_mode):
"""Set new target operation mode."""
self.api.device_control(self.obj_id, "modeSet", {"value": operation_mode})
if self._control_device("modeSet", {"value": operation_mode}):
self._update_data("mode", operation_mode)

def set_swing_mode(self, swing_mode):
"""Set new target swing operation."""
Expand Down Expand Up @@ -110,7 +116,12 @@ def support_humidity(self):
return False

def turn_on(self):
self.api.device_control(self.obj_id, "turnOnOff", {"value": "1"})
if self._control_device("turnOnOff", {"value": "1"}):
self._update_data("state", "true")

ollo69 marked this conversation as resolved.
Show resolved Hide resolved
def turn_off(self):
self.api.device_control(self.obj_id, "turnOnOff", {"value": "0"})
if self._control_device("turnOnOff", {"value": "0"}):
self._update_data("state", "false")

def update(self):
return self._update(use_discovery=True)
15 changes: 11 additions & 4 deletions custom_components/tuya_custom/tuyaha/devices/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,27 @@ def oscillating(self):
return self.data.get("direction")

def set_speed(self, speed):
self.api.device_control(self.obj_id, "windSpeedSet", {"value": speed})
if self._control_device("windSpeedSet", {"value": speed}):
self._update_data("speed", speed)

def oscillate(self, oscillating):
if oscillating:
command = "swingOpen"
else:
command = "swingClose"
self.api.device_control(self.obj_id, command)
if self._control_device(command):
self._update_data("direction", oscillating)

def turn_on(self):
self.api.device_control(self.obj_id, "turnOnOff", {"value": "1"})
if self._control_device("turnOnOff", {"value": "1"}):
self._update_data("state", "true")

def turn_off(self):
self.api.device_control(self.obj_id, "turnOnOff", {"value": "0"})
if self._control_device("turnOnOff", {"value": "0"}):
self._update_data("state", "false")

def update(self):
return self._update(use_discovery=True)

def support_oscillate(self):
if self.oscillating() is None:
Expand Down