Skip to content

Commit

Permalink
Fix SET to CONTROL
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonacox committed Sep 13, 2020
1 parent 621023e commit f8bdc52
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tinytuya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
Crypto = AES = None
import pyaes # https://github.com/ricmoo/pyaes

version_tuple = (1, 0, 2)
version_tuple = (1, 0, 3)
version = __version__ = '%d.%d.%d' % version_tuple
__author__ = 'jasonacox'

Expand Down Expand Up @@ -418,7 +418,7 @@ def set_status(self, on, switch=1):
# open device, send request, then close connection
if isinstance(switch, int):
switch = str(switch) # index and payload is a string
payload = self.generate_payload(SET, {switch:on})
payload = self.generate_payload(CONTROL, {switch:on})

data = self._send_receive(payload)
log.debug('set_status received data=%r', data)
Expand All @@ -437,7 +437,7 @@ def set_value(self, index, value):
if isinstance(index, int):
index = str(index) # index and payload is a string

payload = self.generate_payload(SET, {
payload = self.generate_payload(CONTROL, {
index: value})

data = self._send_receive(payload)
Expand Down Expand Up @@ -467,7 +467,7 @@ def set_timer(self, num_secs):
devices_numbers.sort()
dps_id = devices_numbers[-1]

payload = self.generate_payload(SET, {dps_id:num_secs})
payload = self.generate_payload(CONTROL, {dps_id:num_secs})

data = self._send_receive(payload)
log.debug('set_timer received data=%r', data)
Expand Down Expand Up @@ -637,7 +637,7 @@ def set_colour(self, r, g, b):
#print(BulbDevice)
hexvalue = BulbDevice._rgb_to_hexvalue(r, g, b)

payload = self.generate_payload(SET, {
payload = self.generate_payload(CONTROL, {
self.DPS_INDEX_MODE: self.DPS_MODE_COLOUR,
self.DPS_INDEX_COLOUR: hexvalue})
data = self._send_receive(payload)
Expand All @@ -656,7 +656,7 @@ def set_white(self, brightness, colourtemp):
if not 0 <= colourtemp <= 255:
raise ValueError("The colour temperature needs to be between 0 and 255.")

payload = self.generate_payload(SET, {
payload = self.generate_payload(CONTROL, {
self.DPS_INDEX_MODE: self.DPS_MODE_WHITE,
self.DPS_INDEX_BRIGHTNESS: brightness,
self.DPS_INDEX_COLOURTEMP: colourtemp})
Expand All @@ -674,7 +674,7 @@ def set_brightness(self, brightness):
if not 25 <= brightness <= 255:
raise ValueError("The brightness needs to be between 25 and 255.")

payload = self.generate_payload(SET, {self.DPS_INDEX_BRIGHTNESS: brightness})
payload = self.generate_payload(CONTROL, {self.DPS_INDEX_BRIGHTNESS: brightness})
data = self._send_receive(payload)
return data

Expand All @@ -688,7 +688,7 @@ def set_colourtemp(self, colourtemp):
if not 0 <= colourtemp <= 255:
raise ValueError("The colour temperature needs to be between 0 and 255.")

payload = self.generate_payload(SET, {self.DPS_INDEX_COLOURTEMP: colourtemp})
payload = self.generate_payload(CONTROL, {self.DPS_INDEX_COLOURTEMP: colourtemp})
data = self._send_receive(payload)
return data

Expand Down

0 comments on commit f8bdc52

Please sign in to comment.