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

Commit

Permalink
Merge pull request #4 from nao-pon/climate-fun-mente
Browse files Browse the repository at this point in the history
maintenance to use discovery update
  • Loading branch information
ollo69 authored Jul 2, 2020
2 parents 367a084 + da4c0eb commit 94e5687
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
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)

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")

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

0 comments on commit 94e5687

Please sign in to comment.