index
int64
0
731k
package
stringlengths
2
98
name
stringlengths
1
76
docstring
stringlengths
0
281k
code
stringlengths
4
8.19k
signature
stringlengths
2
42.8k
embed_func_code
listlengths
768
768
729,317
tinytuya.BulbDevice
_hexvalue_to_rgb
Converts the hexvalue used by Tuya for colour representation into an RGB value. Args: hexvalue(string): The hex representation generated by BulbDevice._rgb_to_hexvalue()
@staticmethod def _hexvalue_to_rgb(hexvalue, bulb="A"): """ Converts the hexvalue used by Tuya for colour representation into an RGB value. Args: hexvalue(string): The hex representation generated by BulbDevice._rgb_to_hexvalue() """ if bulb == "A": r = int(hexvalue[0:2], 16) ...
(hexvalue, bulb='A')
[ -0.011556788347661495, -0.08752845972776413, -0.06896181404590607, -0.007133000995963812, -0.02921404503285885, -0.006754090078175068, -0.009505932219326496, 0.06956807523965836, -0.037947945296764374, -0.027338434010744095, 0.037417467683553696, 0.02659955807030201, 0.04486307129263878, 0...
729,318
tinytuya.core
_negotiate_session_key
null
def _negotiate_session_key(self): rkey = self._send_receive_quick( self._negotiate_session_key_generate_step_1(), 2 ) step3 = self._negotiate_session_key_generate_step_3( rkey ) if not step3: return False self._send_receive_quick( step3, None ) self._negotiate_session_key_generate_finalize()...
(self)
[ -0.016313448548316956, -0.061776548624038696, -0.04712773859500885, 0.07901479303836823, 0.004119977820664644, 0.004161593969911337, 0.011726446449756622, 0.02885371632874012, 0.025986840948462486, -0.02058601751923561, 0.03562324494123459, -0.0015316976932808757, 0.018227780237793922, 0.0...
729,319
tinytuya.core
_negotiate_session_key_generate_finalize
null
def _negotiate_session_key_generate_finalize( self ): if IS_PY2: k = [ chr(ord(a)^ord(b)) for (a,b) in zip(self.local_nonce,self.remote_nonce) ] self.local_key = ''.join(k) else: self.local_key = bytes( [ a^b for (a,b) in zip(self.local_nonce,self.remote_nonce) ] ) log.debug("Session...
(self)
[ -0.022203445434570312, -0.07272051274776459, -0.03265655040740967, 0.06144018843770027, 0.00023647563648410141, -0.03929314389824867, -0.0271103885024786, 0.07396135479211807, 0.048392608761787415, -0.014429420232772827, 0.031114906072616577, 0.0001714081154204905, 0.0068527995608747005, 0...
729,320
tinytuya.core
_negotiate_session_key_generate_step_1
null
def _negotiate_session_key_generate_step_1( self ): self.local_nonce = b'0123456789abcdef' # not-so-random random key self.remote_nonce = b'' self.local_key = self.real_local_key return MessagePayload(SESS_KEY_NEG_START, self.local_nonce)
(self)
[ -0.04330030083656311, -0.05063993111252785, -0.03855939209461212, 0.047268617898225784, 0.010754839517176151, -0.011325504630804062, -0.009007726795971394, 0.05833073705434799, 0.036627911031246185, -0.015214805491268635, -0.003237426280975342, 0.05243093892931938, -0.006891876924782991, 0...
729,321
tinytuya.core
_negotiate_session_key_generate_step_3
null
def _negotiate_session_key_generate_step_3( self, rkey ): if not rkey or type(rkey) != TuyaMessage or len(rkey.payload) < 48: # error log.debug("session key negotiation failed on step 1") return False if rkey.cmd != SESS_KEY_NEG_RESP: log.debug("session key negotiation step 2 ret...
(self, rkey)
[ -0.019201796501874924, -0.036707356572151184, -0.061979398131370544, 0.0814194306731224, 0.0026086808647960424, -0.010453782044351101, -0.008633662015199661, 0.05180196836590767, 0.015094613656401634, -0.01997368037700653, 0.047151610255241394, 0.04951490834355354, 0.019725915044546127, 0....
729,322
tinytuya.core
_process_message
null
def _process_message( self, msg, dev_type=None, from_child=None, minresponse=28, decode_response=True ): # null packet, nothing to decode if not msg or len(msg.payload) == 0: log.debug("raw unpacked message = %r", msg) # legacy/default mode avoids persisting socket across commands self._...
(self, msg, dev_type=None, from_child=None, minresponse=28, decode_response=True)
[ 0.04399879276752472, 0.013529629446566105, -0.06287827342748642, 0.016899537295103073, -0.029619187116622925, -0.03175912797451019, 0.01575956866145134, 0.058318402618169785, 0.002204939490184188, -0.048278674483299255, 0.012389659881591797, 0.012569655664265156, -0.0019024477805942297, -0...
729,323
tinytuya.core
_process_response
Override this function in a sub-class if you want to do some processing on the received data
def _process_response(self, response): # pylint: disable=R0201 """ Override this function in a sub-class if you want to do some processing on the received data """ return response
(self, response)
[ -0.03701367601752281, -0.021450307220220566, -0.06394553184509277, 0.020939165726304054, -0.013915379531681538, -0.010028943419456482, -0.016418209299445152, 0.0855192169547081, 0.049245815724134445, -0.018506838008761406, 0.07536689937114716, 0.006627210881561041, 0.059891652315855026, -0...
729,324
tinytuya.core
_receive
null
def _receive(self): # make sure to use the parent's self.seqno and session key if self.parent: return self.parent._receive() # message consists of header + retcode + [data] + crc (4 or 32) + footer min_len_55AA = struct.calcsize(MESSAGE_HEADER_FMT_55AA) + 4 + 4 + len(SUFFIX_BIN) # message co...
(self)
[ -0.003358854679390788, -0.021649671718478203, -0.08881720155477524, -0.01282341405749321, -0.009084447287023067, -0.047468625009059906, -0.00027761352248489857, 0.0740143358707428, 0.042037080973386765, -0.05672520026564598, -0.0017965688602998853, 0.02335180900990963, -0.010968274436891079,...
729,325
tinytuya.core
_recv_all
null
def _recv_all(self, length): tries = 2 data = b'' while length > 0: newdata = self.socket.recv(length) if not newdata or len(newdata) == 0: log.debug("_recv_all(): no data? %r", newdata) # connection closed? tries -= 1 if tries == 0: ...
(self, length)
[ -0.04696296527981758, 0.029955347999930382, -0.06722579896450043, 0.013222049921751022, -0.029498154297471046, -0.018360909074544907, -0.05325395241379738, -0.03313741832971573, 0.0650678426027298, -0.055521633476018906, -0.004098743665963411, 0.021506404504179955, -0.017931146547198296, 0...
729,326
tinytuya.core
_register_child
null
def _register_child(self, child): if child.id in self.children and child != self.children[child.id]: log.debug('Replacing existing child %r!', child.id) self.children[child.id] = child # disable device22 detection as some gateways return "json obj data unvalid" when the gateway is polled without a c...
(self, child)
[ 0.02258240059018135, -0.017452547326683998, -0.010535997338593006, 0.030465979129076004, -0.04645416885614395, 0.015076423063874245, 0.02512430213391781, 0.1197272464632988, 0.009596599265933037, -0.04288077354431152, 0.007971071638166904, 0.03107382543385029, -0.013354192487895489, -0.022...
729,327
tinytuya.BulbDevice
_rgb_to_hexvalue
Convert an RGB value to the hex representation expected by Tuya Bulb. Index (DPS_INDEX_COLOUR) is assumed to be in the format: (Type A) Index: 5 in hex format: rrggbb0hhhssvv (Type B) Index: 24 in hex format: hhhhssssvvvv While r, g and b are just hexadecimal values of...
@staticmethod def _rgb_to_hexvalue(r, g, b, bulb="A"): """ Convert an RGB value to the hex representation expected by Tuya Bulb. Index (DPS_INDEX_COLOUR) is assumed to be in the format: (Type A) Index: 5 in hex format: rrggbb0hhhssvv (Type B) Index: 24 in hex format: hhhhssssvvvv While r...
(r, g, b, bulb='A')
[ -0.01774352788925171, -0.11169569939374924, -0.08298274874687195, -0.011989390477538109, -0.01739712432026863, 0.008924686349928379, -0.023844068869948387, 0.03935522213578224, -0.042684540152549744, -0.02601870894432068, 0.02819334901869297, 0.032023027539253235, 0.06608597934246063, 0.00...
729,328
tinytuya.core
_send_receive
Send single buffer `payload` and receive a single buffer. Args: payload(bytes): Data to send. Set to 'None' to receive only. minresponse(int): Minimum response size expected (default=28 bytes) getresponse(bool): If True, wait for and return response.
def _send_receive(self, payload, minresponse=28, getresponse=True, decode_response=True, from_child=None): """ Send single buffer `payload` and receive a single buffer. Args: payload(bytes): Data to send. Set to 'None' to receive only. minresponse(int): Minimum response size expected (defaul...
(self, payload, minresponse=28, getresponse=True, decode_response=True, from_child=None)
[ 0.00578027218580246, -0.031147794798016548, -0.05875132977962494, 0.021390654146671295, -0.022016111761331558, -0.022016111761331558, -0.06759113073348999, 0.027520140632987022, -0.028750207275152206, -0.08873160183429718, 0.005157420411705971, 0.011477150022983551, -0.024142669513821602, ...
729,329
tinytuya.core
_send_receive_quick
null
def _send_receive_quick(self, payload, recv_retries, from_child=None): # pylint: disable=W0613 if self.parent: return self.parent._send_receive_quick(payload, recv_retries, from_child=self) log.debug("sending payload quick") if self._get_socket(False) is not True: return None enc_payload...
(self, payload, recv_retries, from_child=None)
[ -0.025800103321671486, -0.045998748391866684, -0.055235590785741806, 0.05441948398947716, -0.012009753845632076, -0.03772639110684395, -0.01541328988969326, -0.003978520631790161, 0.014634278602898121, -0.03839411586523056, 0.017379365861415863, 0.03674335405230522, 0.009487241506576538, -...
729,330
tinytuya.core
add_dps_to_request
Add a datapoint (DP) to be included in requests.
def add_dps_to_request(self, dp_indicies): """Add a datapoint (DP) to be included in requests.""" if isinstance(dp_indicies, int): self.dps_to_request[str(dp_indicies)] = None else: self.dps_to_request.update({str(index): None for index in dp_indicies})
(self, dp_indicies)
[ -0.03094371035695076, 0.0033615236170589924, -0.05587206035852432, -0.01986837387084961, -0.053041305392980576, 0.03499523177742958, 0.0025941231288015842, -0.011402642354369164, 0.02575988695025444, -0.030483711510896683, -0.03361523523926735, -0.002342008985579014, 0.004829978570342064, ...
729,331
tinytuya.BulbDevice
brightness
Return brightness value
def brightness(self): """Return brightness value""" return self.status()[self.DPS][self.DPS_INDEX_BRIGHTNESS[self.bulb_type]]
(self)
[ 0.030699901282787323, -0.07401429116725922, -0.0066252201795578, 0.0656859427690506, 0.037251073867082596, -0.026988733559846878, 0.008215098641812801, -0.027964439243078232, 0.025246400386095047, 0.0011194488033652306, -0.046276357024908066, -0.0342194139957428, 0.038819171488285065, -0.0...
729,332
tinytuya.core
close
null
def close(self): self.__del__()
(self)
[ 0.019966455176472664, -0.013121766969561577, 0.02096811681985855, 0.012779532931745052, -0.043338559567928314, -0.04163573309779167, -0.03709486871957779, 0.09355519711971283, -0.0018290758598595858, 0.020150093361735344, -0.03569254279136658, -0.050717465579509735, 0.03766247630119324, 0....
729,333
tinytuya.BulbDevice
colour_hsv
Return colour as HSV value
def colour_hsv(self): """Return colour as HSV value""" hexvalue = self.status()[self.DPS][self.DPS_INDEX_COLOUR[self.bulb_type]] return BulbDevice._hexvalue_to_hsv(hexvalue, self.bulb_type)
(self)
[ -0.016152868047356606, -0.10103294253349304, -0.07194086909294128, -0.01851142942905426, -0.00036881910637021065, 0.0009073654655367136, 0.010045034810900688, 0.03831959888339043, -0.004735919181257486, 0.0016162263927981257, -0.021123703569173813, -0.03950358182191849, 0.06292007118463516, ...
729,334
tinytuya.BulbDevice
colour_rgb
Return colour as RGB value
def colour_rgb(self): """Return colour as RGB value""" hexvalue = self.status()[self.DPS][self.DPS_INDEX_COLOUR[self.bulb_type]] return BulbDevice._hexvalue_to_rgb(hexvalue, self.bulb_type)
(self)
[ -0.013655471615493298, -0.05106046050786972, -0.07863150537014008, 0.04305725172162056, 0.013985604047775269, -0.015706293284893036, 0.007843142375349998, 0.0252701248973608, 0.022408979013562202, -0.023969605565071106, -0.008053227327764034, -0.05938379466533661, 0.06854746490716934, 0.01...
729,335
tinytuya.BulbDevice
colourtemp
Return colour temperature
def colourtemp(self): """Return colour temperature""" return self.status()[self.DPS][self.DPS_INDEX_COLOURTEMP[self.bulb_type]]
(self)
[ 0.04442645236849785, -0.05126677080988884, 0.03553760051727295, 0.031030826270580292, 0.030300479382276535, -0.027272213250398636, -0.03291903808712959, 0.01423285249620676, 0.04392767697572708, -0.02866165153682232, -0.00789575930684805, -0.0361076258122921, 0.00725002633407712, -0.029409...
729,336
tinytuya.core
detect_available_dps
Return which datapoints are supported by the device.
def detect_available_dps(self): """Return which datapoints are supported by the device.""" # device22 devices need a sort of bruteforce querying in order to detect the # list of available dps experience shows that the dps available are usually # in the ranges [1-25] and [100-110] need to split the brute...
(self)
[ 0.0536448135972023, -0.02457973174750805, -0.0829610750079155, 0.0006285100243985653, 0.0022213708143681288, 0.03986581042408943, -0.025153856724500656, -0.09724243730306625, -0.007867308333516121, -0.02294706366956234, -0.023036770522594452, 0.0022079148329794407, -0.021888520568609238, -...
729,337
tinytuya.core
find
Mainly here for backwards compatibility. Calling tinytuya.find_device() directly is recommended. Parameters: did = The specific Device ID you are looking for (returns only IP and Version) Response: (ip, version)
@staticmethod def find(did): """ Mainly here for backwards compatibility. Calling tinytuya.find_device() directly is recommended. Parameters: did = The specific Device ID you are looking for (returns only IP and Version) Response: (ip, version) """ bcast_data = find_device(de...
(did)
[ 0.049842942506074905, -0.08148809522390366, -0.030421003699302673, -0.03312509134411812, -0.008171647787094116, -0.033691488206386566, -0.017476089298725128, 0.012186672538518906, -0.010350449942052364, -0.06343647092580795, -0.03986704349517822, -0.010377855971455574, -0.014982116408646107,...
729,338
tinytuya.core
generate_payload
Generate the payload to send. Args: command(str): The type of command. This is one of the entries from payload_dict data(dict, optional): The data to send. This is what will be passed via the 'dps' entry gwId(str, optional): Will be u...
def generate_payload(self, command, data=None, gwId=None, devId=None, uid=None, rawData=None, reqType=None): """ Generate the payload to send. Args: command(str): The type of command. This is one of the entries from payload_dict data(dict, optional): The data to send. ...
(self, command, data=None, gwId=None, devId=None, uid=None, rawData=None, reqType=None)
[ 0.008312447927892208, -0.029635682702064514, -0.04864393547177315, -0.00589001877233386, -0.01475923415273428, -0.0273109320551157, -0.04930815100669861, 0.008878983557224274, -0.010012054815888405, -0.07404036819934845, 0.007013322319835424, 0.026627182960510254, -0.027721181511878967, 0....
729,339
tinytuya.core
heartbeat
Send a keep-alive HEART_BEAT command to keep the TCP connection open. Devices only send an empty-payload response, so no need to wait for it. Args: nowait(bool): True to send without waiting for response.
def heartbeat(self, nowait=True): """ Send a keep-alive HEART_BEAT command to keep the TCP connection open. Devices only send an empty-payload response, so no need to wait for it. Args: nowait(bool): True to send without waiting for response. """ # open device, send request, then close c...
(self, nowait=True)
[ 0.03801944851875305, -0.06208879500627518, -0.021557604894042015, -0.06100459024310112, 0.05843864008784294, -0.02717740088701248, -0.026906348764896393, 0.06367896497249603, -0.0458618625998497, -0.06866630166769028, -0.017708677798509598, -0.06479930877685547, 0.01940726675093174, 0.0008...
729,340
tinytuya.core
product
Request AP_CONFIG Product Info from device. [BETA]
def product(self): """ Request AP_CONFIG Product Info from device. [BETA] """ # open device, send request, then close connection payload = self.generate_payload(AP_CONFIG) data = self._send_receive(payload, 0) log.debug("product received data=%r", data) return data
(self)
[ 0.029115773737430573, -0.001644022180698812, -0.05686098337173462, -0.06290553510189056, 0.06431124359369278, -0.05190585181117058, -0.01565609872341156, -0.05777469277381897, 0.0518355667591095, -0.037497323006391525, -0.03386004641652107, -0.05471727252006531, 0.0033144012559205294, 0.00...
729,341
tinytuya.core
receive
Poll device to read any payload in the buffer. Timeout results in None returned.
def receive(self): """ Poll device to read any payload in the buffer. Timeout results in None returned. """ return self._send_receive(None)
(self)
[ 0.012618943117558956, -0.023828232660889626, -0.04942277818918228, -0.02009180188179016, 0.04144040495157242, 0.007893208414316177, 0.007400678936392069, -0.009315598756074905, -0.021008925512433052, -0.05692960321903229, -0.006844460032880306, -0.018070733174681664, -0.004475223831832409, ...
729,342
tinytuya.core
send
Send single buffer `payload`. Args: payload(bytes): Data to send.
def send(self, payload): """ Send single buffer `payload`. Args: payload(bytes): Data to send. """ return self._send_receive(payload, 0, getresponse=False)
(self, payload)
[ -0.013845069333910942, -0.04760194942355156, -0.10029386729001999, 0.003960854839533567, 0.006138429045677185, -0.010619034059345722, -0.06344536691904068, 0.03960854932665825, -0.005730694159865379, -0.05530858784914017, 0.014615734107792377, -0.06380381435155869, -0.017124872654676437, 0...
729,343
tinytuya.BulbDevice
set_brightness
Set the brightness value of an rgb bulb. Args: brightness(int): Value for the brightness (25-255). nowait(bool): True to send without waiting for response.
def set_brightness(self, brightness, nowait=False): """ Set the brightness value of an rgb bulb. Args: brightness(int): Value for the brightness (25-255). nowait(bool): True to send without waiting for response. """ if self.bulb_type == "A" and not 25 <= brightness <= 255: re...
(self, brightness, nowait=False)
[ 0.008521855808794498, -0.08079981803894043, -0.10995202511548996, 0.029917357489466667, 0.01786624826490879, -0.00797190424054861, -0.04097377136349678, -0.007670626975595951, -0.020448628813028336, -0.03921392932534218, -0.01821056567132473, -0.012022416107356548, 0.001334229949861765, 0....
729,344
tinytuya.BulbDevice
set_brightness_percentage
Set the brightness value of an rgb bulb. Args: brightness(int): Value for the brightness in percent (0-100) nowait(bool): True to send without waiting for response.
def set_brightness_percentage(self, brightness=100, nowait=False): """ Set the brightness value of an rgb bulb. Args: brightness(int): Value for the brightness in percent (0-100) nowait(bool): True to send without waiting for response. """ if not 0 <= brightness <= 100: retur...
(self, brightness=100, nowait=False)
[ -0.023884199559688568, -0.05296694114804268, -0.09255582094192505, 0.03944346681237221, 0.014650430530309677, -0.0029900691006332636, -0.024538561701774597, -0.026010874658823013, -0.01136044505983591, -0.03442669287323952, 0.0036966889165341854, -0.019939852878451347, 0.019140077754855156, ...
729,345
tinytuya.BulbDevice
set_bulb_type
null
def set_bulb_type(self, type): self.bulb_type = type
(self, type)
[ 0.003732899436727166, 0.016832798719406128, -0.006021962966769934, -0.018832646310329437, -0.053951047360897064, -0.05778932198882103, -0.009227996692061424, 0.01706596463918686, -0.0870247632265091, -0.02342422492802143, -0.04896488040685654, -0.012008054181933403, -0.020805589854717255, ...
729,346
tinytuya.BulbDevice
set_colour
Set colour of an rgb bulb. Args: r(int): Value for the colour Red as int from 0-255. g(int): Value for the colour Green as int from 0-255. b(int): Value for the colour Blue as int from 0-255. nowait(bool): True to send without waiting for response. ...
def set_colour(self, r, g, b, nowait=False): """ Set colour of an rgb bulb. Args: r(int): Value for the colour Red as int from 0-255. g(int): Value for the colour Green as int from 0-255. b(int): Value for the colour Blue as int from 0-255. nowait(bool): True to send without ...
(self, r, g, b, nowait=False)
[ -0.007313096895813942, -0.08344808220863342, -0.1322716623544693, 0.02405111864209175, -0.004114506766200066, 0.006107693538069725, -0.05106354504823685, 0.026556840166449547, -0.016268199309706688, -0.062339287251234055, -0.0000023728412088530604, -0.012006577104330063, 0.01221538707613945,...
729,347
tinytuya.BulbDevice
set_colourtemp
Set the colour temperature of an rgb bulb. Args: colourtemp(int): Value for the colour temperature (0-255). nowait(bool): True to send without waiting for response.
def set_colourtemp(self, colourtemp, nowait=False): """ Set the colour temperature of an rgb bulb. Args: colourtemp(int): Value for the colour temperature (0-255). nowait(bool): True to send without waiting for response. """ if not self.has_colourtemp: log.debug("set_colourte...
(self, colourtemp, nowait=False)
[ 0.027678286656737328, -0.04542849212884903, -0.08672028034925461, 0.014008371159434319, 0.01665962114930153, -0.011169090867042542, -0.0632915124297142, 0.025158658623695374, 0.002458516275510192, -0.06675130128860474, 0.005626852624118328, -0.01599210686981678, -0.021774087101221085, -0.0...
729,348
tinytuya.BulbDevice
set_colourtemp_percentage
Set the colour temperature of an rgb bulb. Args: colourtemp(int): Value for the colour temperature in percentage (0-100). nowait(bool): True to send without waiting for response.
def set_colourtemp_percentage(self, colourtemp=100, nowait=False): """ Set the colour temperature of an rgb bulb. Args: colourtemp(int): Value for the colour temperature in percentage (0-100). nowait(bool): True to send without waiting for response. """ if not 0 <= colourtemp <= 100:...
(self, colourtemp=100, nowait=False)
[ -0.005619272124022245, -0.03828355669975281, -0.07881481945514679, 0.024416642263531685, 0.0191961582750082, 0.01609649509191513, -0.043395280838012695, -0.005034686531871557, 0.00004673285729950294, -0.061231937259435654, 0.034259431064128876, -0.022386454045772552, 0.00016469792171847075, ...
729,349
tinytuya.core
set_dpsUsed
null
def set_dpsUsed(self, dps_to_request): self.dps_to_request = dps_to_request
(self, dps_to_request)
[ 0.015324109233915806, 0.00954616628587246, 0.003230205038562417, 0.01887461356818676, -0.021755211055278778, 0.06558384001255035, -0.03285891190171242, -0.05828185752034187, 0.029207920655608177, -0.02388216368854046, -0.005350877530872822, -0.05081240087747574, 0.013808446004986763, -0.00...
729,350
tinytuya.BulbDevice
set_hsv
Set colour of an rgb bulb using h, s, v. Args: h(float): colour Hue as float from 0-1 s(float): colour Saturation as float from 0-1 v(float): colour Value as float from 0-1 nowait(bool): True to send without waiting for response.
def set_hsv(self, h, s, v, nowait=False): """ Set colour of an rgb bulb using h, s, v. Args: h(float): colour Hue as float from 0-1 s(float): colour Saturation as float from 0-1 v(float): colour Value as float from 0-1 nowait(bool): True to send without waiting for response. ...
(self, h, s, v, nowait=False)
[ -0.00991364661604166, -0.09794796258211136, -0.13530099391937256, -0.010149461217224598, -0.011479455977678299, 0.012639664113521576, -0.035221271216869354, 0.04648377746343613, -0.025015216320753098, -0.031542565673589706, -0.02410968765616417, 0.009262798354029655, 0.0286184623837471, -0...
729,351
tinytuya.BulbDevice
set_mode
Set bulb mode Args: mode(string): white,colour,scene,music nowait(bool): True to send without waiting for response.
def set_mode(self, mode="white", nowait=False): """ Set bulb mode Args: mode(string): white,colour,scene,music nowait(bool): True to send without waiting for response. """ payload = self.generate_payload( CONTROL, {self.DPS_INDEX_MODE[self.bulb_type]: mode} ) data = s...
(self, mode='white', nowait=False)
[ 0.041000846773386, -0.0019738583359867334, -0.04221979156136513, -0.0668572336435318, 0.027610931545495987, -0.002280903048813343, -0.03893233463168144, 0.004402512218803167, -0.0061593614518642426, -0.008375623263418674, -0.08081968873739243, -0.025006823241710663, -0.04587662220001221, 0...
729,352
tinytuya.core
set_multiple_values
Set multiple indexes at the same time Args: data(dict): array of index/value pairs to set nowait(bool): True to send without waiting for response.
def set_multiple_values(self, data, nowait=False): """ Set multiple indexes at the same time Args: data(dict): array of index/value pairs to set nowait(bool): True to send without waiting for response. """ out = {} for i in data: out[str(i)] = data[i] payload = self.g...
(self, data, nowait=False)
[ 0.007297394331544638, -0.0008465381106361747, -0.1268831044435501, -0.010295339860022068, -0.02324754185974598, 0.022529469802975655, -0.0669960007071495, -0.027520062401890755, 0.023103926330804825, -0.008729048073291779, -0.05245506763458252, -0.00635941419750452, -0.0013362847967073321, ...
729,353
tinytuya.core
set_retry
null
def set_retry(self, retry): self.retry = retry
(self, retry)
[ 0.0020649710204452276, 0.039500895887613297, -0.027927067130804062, 0.08106676489114761, 0.005254019051790237, -0.023031087592244148, -0.004179900977760553, 0.03360573947429657, 0.04226529225707054, 0.0023980308324098587, 0.017818700522184372, 0.046928130090236664, 0.02952575497329235, 0.0...
729,354
tinytuya.BulbDevice
set_scene
Set to scene mode Args: scene(int): Value for the scene as int from 1-4. nowait(bool): True to send without waiting for response.
def set_scene(self, scene, nowait=False): """ Set to scene mode Args: scene(int): Value for the scene as int from 1-4. nowait(bool): True to send without waiting for response. """ if not 1 <= scene <= 4: return error_json( ERR_RANGE, "set_scene: The value for scen...
(self, scene, nowait=False)
[ -0.014820298179984093, 0.021882811561226845, -0.09250793606042862, -0.028579389676451683, -0.001684436690993607, 0.05448746681213379, -0.054414279758930206, 0.02859768643975258, -0.01634806953370571, -0.014628183096647263, -0.03655673563480377, 0.04347287490963936, -0.06363580375909805, 0....
729,355
tinytuya.core
set_sendWait
null
def set_sendWait(self, s): self.sendWait = s
(self, s)
[ 0.005107562988996506, 0.03161167353391647, -0.052490562200546265, 0.04614062234759331, -0.014925817959010601, -0.00223887269385159, -0.009326479397714138, 0.058771487325429916, -0.005055797286331654, -0.023311885073781013, -0.025796644389629364, -0.024709561839699745, -0.0186357032507658, ...
729,356
tinytuya.core
set_socketNODELAY
null
def set_socketNODELAY(self, nodelay): self.socketNODELAY = nodelay if self.socket: if nodelay: self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) else: self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 0)
(self, nodelay)
[ -0.01158624142408371, -0.034559112042188644, 0.005393894389271736, 0.017722176387906075, -0.001906088669784367, -0.011759818531572819, -0.07317991554737091, 0.06043939292430878, -0.03181660175323486, -0.0387423112988472, -0.042213842272758484, -0.05071909725666046, -0.0035518123768270016, ...
729,357
tinytuya.core
set_socketPersistent
null
def set_socketPersistent(self, persist): self.socketPersistent = persist if self.socket and not persist: self.socket.close() self.socket = None
(self, persist)
[ 0.010159250348806381, 0.02036912925541401, -0.006758770439773798, 0.05511646717786789, 0.017787126824259758, -0.018107766285538673, -0.035709258168935776, 0.06449943035840988, -0.0009360812837257981, 0.003119919216260314, -0.03253660351037979, -0.05569024384021759, -0.014251640066504478, -...
729,358
tinytuya.core
set_socketRetryDelay
null
def set_socketRetryDelay(self, delay): self.socketRetryDelay = delay
(self, delay)
[ -0.0016402387991547585, 0.02638341672718525, -0.012074950151145458, 0.0409361757338047, 0.008196831680834293, -0.00004887181057711132, -0.02291099540889263, 0.007712612394243479, 0.008297165855765343, 0.005588154308497906, -0.03598055988550186, -0.015739312395453453, 0.030152475461363792, ...
729,359
tinytuya.core
set_socketRetryLimit
null
def set_socketRetryLimit(self, limit): self.socketRetryLimit = limit
(self, limit)
[ -0.0073384433053433895, 0.011178276501595974, -0.033431168645620346, 0.05003444850444794, -0.031098760664463043, 0.01802000403404236, -0.02719413861632347, 0.006781257223337889, -0.024343417957425117, -0.040324725210666656, -0.00989113375544548, 0.0032070595771074295, 0.009554230608046055, ...
729,360
tinytuya.core
set_socketTimeout
null
def set_socketTimeout(self, s): self.connection_timeout = s if self.socket: self.socket.settimeout(s)
(self, s)
[ -0.02785167656838894, -0.009383405558764935, 0.016415219753980637, 0.03825012594461441, -0.024158939719200134, -0.006260196678340435, -0.05066947266459465, 0.03488808125257492, -0.023534297943115234, -0.034355297684669495, -0.029817460104823112, -0.0009243320673704147, -0.020062025636434555,...
729,361
tinytuya.core
set_status
Set status of the device to 'on' or 'off'. Args: on(bool): True for 'on', False for 'off'. switch(int): The switch to set nowait(bool): True to send without waiting for response.
def set_status(self, on, switch=1, nowait=False): """ Set status of the device to 'on' or 'off'. Args: on(bool): True for 'on', False for 'off'. switch(int): The switch to set nowait(bool): True to send without waiting for response. """ # open device, send request, then clos...
(self, on, switch=1, nowait=False)
[ 0.026783239096403122, -0.0037048105150461197, -0.012725980021059513, -0.030707010999321938, 0.033246949315071106, -0.030251571908593178, -0.03573434054851532, 0.014679106883704662, -0.015695083886384964, -0.05209506303071976, -0.07125847786664963, -0.01977650634944439, 0.002769849495962262, ...
729,362
tinytuya.core
set_timer
Set a timer. Args: num_secs(int): Number of seconds dps_id(int): DPS Index for Timer nowait(bool): True to send without waiting for response.
def set_timer(self, num_secs, dps_id=0, nowait=False): """ Set a timer. Args: num_secs(int): Number of seconds dps_id(int): DPS Index for Timer nowait(bool): True to send without waiting for response. """ # Query status, pick last device id as that is probably the timer i...
(self, num_secs, dps_id=0, nowait=False)
[ 0.030608296394348145, 0.0027414909563958645, -0.012004162184894085, 0.005496886558830738, 0.014052748680114746, 0.010724954307079315, -0.07367496192455292, 0.039748143404722214, -0.03255491703748703, -0.029403245076537132, -0.06844689697027206, -0.003522456856444478, 0.020430250093340874, ...
729,363
tinytuya.core
set_value
Set int value of any index. Args: index(int): index to set value(int): new value for the index nowait(bool): True to send without waiting for response.
def set_value(self, index, value, nowait=False): """ Set int value of any index. Args: index(int): index to set value(int): new value for the index nowait(bool): True to send without waiting for response. """ # open device, send request, then close connection if isinstanc...
(self, index, value, nowait=False)
[ 0.015926962718367577, -0.010569044388830662, -0.09093782305717468, -0.04245966672897339, 0.032184209674596786, 0.021817002445459366, -0.04532211646437645, 0.016220547258853912, -0.007917609065771103, -0.08161651343107224, -0.06521247327327728, 0.011660812422633171, -0.013679206371307373, 0...
729,364
tinytuya.BulbDevice
set_version
Set the Tuya device version 3.1 or 3.3 for BulbDevice Attempt to determine BulbDevice Type: A or B based on: Type A has keys 1-5 (default) Type B has keys 20-29 Type C is Feit type bulbs from costco
def set_version(self, version): # pylint: disable=W0621 """ Set the Tuya device version 3.1 or 3.3 for BulbDevice Attempt to determine BulbDevice Type: A or B based on: Type A has keys 1-5 (default) Type B has keys 20-29 Type C is Feit type bulbs from costco """ super(BulbDev...
(self, version)
[ -0.004325468093156815, -0.05387043580412865, -0.048605479300022125, 0.01561365183442831, -0.031093770638108253, -0.04700310155749321, -0.04261563718318939, 0.017282795161008835, -0.03544308617711067, -0.024798713624477386, -0.022490525618195534, 0.00627598213031888, -0.03323027491569519, 0...
729,365
tinytuya.BulbDevice
set_white
Set white coloured theme of an rgb bulb. Args: brightness(int): Value for the brightness (A:25-255 or B:10-1000) colourtemp(int): Value for the colour temperature (A:0-255, B:0-1000). nowait(bool): True to send without waiting for response. Default: Max...
def set_white(self, brightness=-1, colourtemp=-1, nowait=False): """ Set white coloured theme of an rgb bulb. Args: brightness(int): Value for the brightness (A:25-255 or B:10-1000) colourtemp(int): Value for the colour temperature (A:0-255, B:0-1000). nowait(bool): True to send with...
(self, brightness=-1, colourtemp=-1, nowait=False)
[ 0.025644849985837936, -0.06314332038164139, -0.07476898282766342, 0.024068167433142662, 0.008078128099441528, -0.010979794897139072, -0.05592476949095726, 0.019167151302099228, -0.0006713964394293725, -0.014598567970097065, 0.0027805666904896498, -0.002053962554782629, 0.022282525897026062, ...
729,366
tinytuya.BulbDevice
set_white_percentage
Set white coloured theme of an rgb bulb. Args: brightness(int): Value for the brightness in percent (0-100) colourtemp(int): Value for the colour temperature in percent (0-100) nowait(bool): True to send without waiting for response.
def set_white_percentage(self, brightness=100, colourtemp=0, nowait=False): """ Set white coloured theme of an rgb bulb. Args: brightness(int): Value for the brightness in percent (0-100) colourtemp(int): Value for the colour temperature in percent (0-100) nowait(bool): True to send ...
(self, brightness=100, colourtemp=0, nowait=False)
[ -0.012731976807117462, -0.06030159443616867, -0.07425141334533691, 0.037716176360845566, 0.013949817977845669, 0.0009675841429270804, -0.04911959916353226, -0.000013388614206633065, 0.0035151327028870583, -0.030851978808641434, 0.03635071590542793, -0.011421875096857548, 0.03417336568236351,...
729,367
tinytuya.BulbDevice
state
Return state of Bulb
def state(self): """Return state of Bulb""" status = self.status() state = {} if not status: return error_json(ERR_JSON, "state: empty response") if "Error" in status.keys(): return error_json(ERR_JSON, status["Error"]) if self.DPS not in status.keys(): return error_json(...
(self)
[ 0.008718681521713734, -0.06265055388212204, -0.043983094394207, -0.01293012872338295, -0.023662980645895004, -0.015493618324398994, -0.0681343600153923, -0.013559263199567795, 0.04770156368613243, -0.052997563034296036, -0.04458405822515488, 0.01200990192592144, -0.02914678305387497, 0.011...
729,368
tinytuya.core
status
Return device status.
def status(self, nowait=False): """Return device status.""" query_type = DP_QUERY log.debug("status() entry (dev_type is %s)", self.dev_type) payload = self.generate_payload(query_type) data = self._send_receive(payload, 0, getresponse=(not nowait)) log.debug("status() received data=%r", data) ...
(self, nowait=False)
[ 0.04589230939745903, -0.025067072361707687, -0.06892988085746765, -0.05368120223283768, 0.08037552982568741, -0.033386196941137314, -0.02477453276515007, -0.04442960396409035, 0.02409803308546543, -0.06746717542409897, -0.040041495114564896, -0.06161636486649513, -0.023074140772223473, -0....
729,369
tinytuya.core
subdev_query
Query for a list of sub-devices and their status
def subdev_query( self, nowait=False ): """Query for a list of sub-devices and their status""" # final payload should look like: {"data":{"cids":[]},"reqType":"subdev_online_stat_query"} payload = self.generate_payload(LAN_EXT_STREAM, rawData={"cids":[]}, reqType='subdev_online_stat_query') return self....
(self, nowait=False)
[ 0.016070310026407242, -0.020421601831912994, -0.03047638013958931, -0.023819424211978912, 0.05391441658139229, 0.025240961462259293, 0.013357252813875675, -0.05887246131896973, 0.0146747762337327, -0.049615129828453064, -0.04666804149746895, -0.022467229515314102, -0.020733647048473358, -0...
729,370
tinytuya.BulbDevice
turn_off
Turn the device on
def turn_off(self, switch=0, nowait=False): """Turn the device on""" if switch == 0: switch = self.DPS_INDEX_ON[self.bulb_type] self.set_status(False, switch, nowait=nowait)
(self, switch=0, nowait=False)
[ 0.01897341012954712, 0.03050045296549797, 0.026629040017724037, -0.0012021869188174605, -0.052560530602931976, -0.048584483563899994, -0.031825803220272064, 0.06382599472999573, -0.028739135712385178, -0.01606113091111183, -0.08245062828063965, -0.006766252685338259, -0.024571262300014496, ...
729,371
tinytuya.BulbDevice
turn_on
Turn the device on
def turn_on(self, switch=0, nowait=False): """Turn the device on""" if switch == 0: switch = self.DPS_INDEX_ON[self.bulb_type] self.set_status(True, switch, nowait=nowait)
(self, switch=0, nowait=False)
[ 0.002358748810365796, 0.010552182793617249, 0.012664364650845528, 0.012673093006014824, 0.00295880064368248, -0.021907344460487366, -0.01165191363543272, 0.052193593233823776, -0.041266102343797684, -0.003955977503210306, -0.06738035380840302, -0.018171748146414757, 0.008793485350906849, 0...
729,372
tinytuya.core
updatedps
Request device to update index. Args: index(array): list of dps to update (ex. [4, 5, 6, 18, 19, 20]) nowait(bool): True to send without waiting for response.
def updatedps(self, index=None, nowait=False): """ Request device to update index. Args: index(array): list of dps to update (ex. [4, 5, 6, 18, 19, 20]) nowait(bool): True to send without waiting for response. """ if index is None: index = [1] log.debug("updatedps() entry...
(self, index=None, nowait=False)
[ 0.025323454290628433, -0.012328523211181164, -0.08354635536670685, -0.03773966059088707, 0.020448163151741028, 0.0004724034224636853, -0.037283699959516525, -0.020869050174951553, 0.03837099298834801, -0.0034175263717770576, -0.07113014161586761, -0.0855104997754097, -0.020500773563981056, ...
729,373
tinytuya.Cloud
Cloud
null
class Cloud(object): def __init__(self, apiRegion=None, apiKey=None, apiSecret=None, apiDeviceID=None, new_sign_algorithm=True, initial_token=None, **extrakw): """ Tuya Cloud IoT Platform Access Args: initial_token: The auth token from a previous run. It will be refreshed if it...
(apiRegion=None, apiKey=None, apiSecret=None, apiDeviceID=None, new_sign_algorithm=True, initial_token=None, **extrakw)
[ -0.012745682150125504, -0.07615730166435242, -0.043971020728349686, 0.04878628998994827, -0.021964389830827713, -0.03108805976808071, -0.06471047550439835, 0.03729722648859024, -0.047476876527071, -0.032629791647195816, 0.012714003212749958, 0.022091107442975044, -0.0026465507689863443, -0...
729,374
tinytuya.Cloud
__init__
Tuya Cloud IoT Platform Access Args: initial_token: The auth token from a previous run. It will be refreshed if it has expired Playload Construction - Header Data: Parameter Type Required Description client_id String Yes client_id s...
def __init__(self, apiRegion=None, apiKey=None, apiSecret=None, apiDeviceID=None, new_sign_algorithm=True, initial_token=None, **extrakw): """ Tuya Cloud IoT Platform Access Args: initial_token: The auth token from a previous run. It will be refreshed if it has expired Playload Construction - H...
(self, apiRegion=None, apiKey=None, apiSecret=None, apiDeviceID=None, new_sign_algorithm=True, initial_token=None, **extrakw)
[ -0.006221448071300983, -0.07108040153980255, -0.042617637664079666, 0.026071742177009583, -0.0035482817329466343, -0.03596102446317673, -0.052373021841049194, 0.04560163617134094, -0.06721650809049606, -0.023470306769013405, 0.009793640114367008, 0.037376511842012405, -0.0033713458105921745,...
729,375
tinytuya.Cloud
_build_mapping
null
@staticmethod def _build_mapping( src, dst ): # merge multiple DPS sets from result['status'] and result['functions'] into a single result for mapp in src: try: code = mapp['code'] dp_id = code if 'dp_id' not in mapp else str(mapp['dp_id']) if dp_id in dst: ...
(src, dst)
[ -0.004655725322663784, -0.03887971490621567, -0.05859808251261711, -0.028389248996973038, -0.05273084715008736, 0.007556850090622902, -0.03520341217517853, -0.03559332340955734, 0.06338842213153839, -0.02213210240006447, -0.010249094106256962, 0.04474695026874542, -0.0029243340250104666, 0...
729,376
tinytuya.Cloud
_get_all_devices
null
def _get_all_devices( self, uid=None, device_ids=None ): fetches = 0 our_result = { 'result': [] } last_row_key = None has_more = True total = 0 if uid: # get device list for specified user id query = {'page_size':'75', 'source_type': 'tuyaUser', 'source_id': uid} # API d...
(self, uid=None, device_ids=None)
[ -0.045897483825683594, -0.030617257580161095, -0.050025228410959244, 0.019559448584914207, -0.0009070859523490071, 0.02823149785399437, -0.043473854660987854, -0.049949489533901215, -0.004769153892993927, -0.02459605224430561, 0.004818857181817293, -0.023005547001957893, -0.01723995804786682...
729,377
tinytuya.Cloud
_get_hw_addresses
null
def _get_hw_addresses( self, maclist, devices ): while devices: # returns id, mac, uuid (and sn if available) uri = 'devices/factory-infos?device_ids=%s' % (",".join(devices[:50])) result = self._tuyaplatform(uri) log.debug( json.dumps( result, indent=2 ) ) if 'result' in res...
(self, maclist, devices)
[ 0.02616165392100811, 0.009819458238780499, -0.05755563825368881, -0.06777282059192657, -0.046737439930438995, -0.020257605239748955, -0.041964706033468246, -0.04850511997938156, -0.04691420868039131, 0.01691669039428234, -0.019479826092720032, 0.0029166708700358868, 0.01186112780123949, 0....
729,378
tinytuya.Cloud
_getdevice
null
def _getdevice(self, param='status', deviceid=None): if not self.token: return self.error if not deviceid: return error_json( ERR_PARAMS, "Missing DeviceID Parameter" ) uri = 'iot-03/devices/%s/%s' % (deviceid, param) response_dict = self._tuyaplatform(uri...
(self, param='status', deviceid=None)
[ 0.02761833742260933, 0.014908136799931526, 0.01753845438361168, -0.02241174876689911, 0.026375241577625275, -0.011944524943828583, -0.002009896095842123, 0.040679845958948135, -0.05927222967147827, -0.04147254303097725, -0.0018297373317182064, -0.014502779580652714, 0.0073279570788145065, ...
729,379
tinytuya.Cloud
_gettoken
null
def _gettoken(self): # Get Oauth Token from tuyaPlatform self.token = None response_dict = self._tuyaplatform('token?grant_type=1') if not response_dict or 'success' not in response_dict or not response_dict['success']: self.error = error_json( ERR_CLOUDTOKEN, "Cloud _get...
(self)
[ 0.01465886551886797, -0.02077619545161724, -0.00037286357837729156, 0.08802894502878189, 0.04882500693202019, -0.013588805682957172, 0.010236584581434727, 0.04844622313976288, 0.00459746690467, -0.030435137450695038, 0.04382508248090744, -0.006344599183648825, 0.008693047799170017, -0.0345...
729,380
tinytuya.Cloud
_getuid
null
def _getuid(self, deviceid=None): # Get user ID (UID) for deviceid if not self.token: return self.error if not deviceid: return error_json( ERR_PARAMS, "_getuid() requires deviceID parameter" ) uri = 'devices/%s' % deviceid response_dict = self._tuyapl...
(self, deviceid=None)
[ -0.03716174140572548, -0.00240612355992198, 0.06096114590764046, 0.05724136158823967, 0.022228427231311798, 0.007024255581200123, 0.03057085908949375, 0.051138024777173996, -0.04026758298277855, -0.05724136158823967, 0.014843028038740158, 0.02753724902868271, -0.023438261821866035, 0.02484...
729,381
tinytuya.Cloud
_tuyaplatform
Handle GET and POST requests to Tuya Cloud
def _tuyaplatform(self, uri, action='GET', post=None, ver='v1.0', recursive=False, query=None, content_type=None): """ Handle GET and POST requests to Tuya Cloud """ # Build URL and Header if ver: url = "https://%s/%s/%s" % (self.urlhost, ver, uri) elif uri[0] == '/': url = "http...
(self, uri, action='GET', post=None, ver='v1.0', recursive=False, query=None, content_type=None)
[ -0.015370008535683155, -0.06892362236976624, -0.04148292914032936, 0.04598931595683098, -0.04800109937787056, -0.006568465381860733, -0.06844079494476318, 0.03947114571928978, -0.04373612254858017, -0.02552950382232666, 0.032771915197372437, 0.022411242127418518, 0.011135208420455456, -0.0...
729,382
tinytuya.Cloud
_update_device_list
null
def _update_device_list( self, result1, result2 ): for new_device in result2: if 'id' not in new_device or not new_device['id']: continue found = False for existing_device in result1: if 'id' in existing_device and existing_device['id'] == new_device['id']: ...
(self, result1, result2)
[ 0.025576597079634666, -0.005221888422966003, -0.06208137795329094, 0.013059565797448158, 0.010569722391664982, -0.020364396274089813, -0.027087941765785217, -0.03361772373318672, 0.06258516013622284, 0.018969310447573662, -0.03419901058077812, -0.06909556686878204, 0.010095005854964256, 0....
729,383
tinytuya.Cloud
cloudrequest
Make a generic cloud request and return the results. Args: url: Required. The URL to fetch, i.e. "/v1.0/devices/0011223344556677/logs" action: Optional. GET, POST, DELETE, or PUT. Defaults to GET, unless POST data is supplied. post: Optional. POST body data. Wil...
def cloudrequest(self, url, action=None, post=None, query=None): """ Make a generic cloud request and return the results. Args: url: Required. The URL to fetch, i.e. "/v1.0/devices/0011223344556677/logs" action: Optional. GET, POST, DELETE, or PUT. Defaults to GET, unless POST data is supp...
(self, url, action=None, post=None, query=None)
[ -0.02177347056567669, -0.043869245797395706, -0.05504247173666954, 0.029848992824554443, -0.004051190335303545, 0.010358513332903385, -0.029347630217671394, -0.02250760793685913, -0.0028291186317801476, -0.04293814301490784, 0.008760419674217701, 0.009046913124620914, -0.01784314401447773, ...
729,384
tinytuya.Cloud
filter_devices
null
def filter_devices( self, devs, ip_list=None ): json_mac_data = {} # mutable json_mac_data will be modified self._get_hw_addresses( json_mac_data, [i['id'] for i in devs] ) tuyadevices = [] icon_host = 'https://images.' + self.urlhost.split( '.', 1 )[1] + '/' for i in devs: dev_id = i['i...
(self, devs, ip_list=None)
[ 0.02504865452647209, -0.03949839249253273, -0.037059538066387177, -0.02614888735115528, -0.05904587730765343, -0.039058297872543335, -0.0393516942858696, -0.02867942675948143, 0.0027574608102440834, 0.05490166321396828, -0.008283843286335468, -0.00006095696153352037, -0.013771259225904942, ...
729,385
tinytuya.Cloud
format_timestamp
null
@staticmethod def format_timestamp( ts ): # converts a 10-digit unix timestamp to the 13-digit stamp the servers expect if type(ts) != int: if len(str(int(ts))) == 10: ts = int( ts * 1000 ) else: ts = int( ts ) elif len(str(ts)) == 10: ts *= 1000 return ts...
(ts)
[ -0.015256487764418125, 0.04284800589084625, -0.008291367441415787, 0.06284374743700027, -0.0028936315793544054, -0.06354860216379166, -0.02626527100801468, 0.08651216328144073, 0.011750740930438042, -0.04800460860133171, 0.0026061234530061483, 0.00792502611875534, -0.011453958228230476, -0...
729,386
tinytuya.Cloud
getconnectstatus
Get the device Cloud connect status.
def getconnectstatus(self, deviceid=None): """ Get the device Cloud connect status. """ if not self.token: return self.error if not deviceid: return error_json( ERR_PARAMS, "Missing DeviceID Parameter" ) uri = 'devices/%s' % (deviceid) response...
(self, deviceid=None)
[ -0.027921847999095917, -0.08419938385486603, 0.028182150796055794, -0.00046230919542722404, 0.035123568028211594, 0.028390394523739815, -0.01848152093589306, 0.022299300879240036, 0.01359649933874607, -0.07496730238199234, -0.0256658885627985, -0.057301394641399384, -0.004310186021029949, ...
729,387
tinytuya.Cloud
getdevicelog
Get the logs for a device. https://developer.tuya.com/en/docs/cloud/0a30fc557f?id=Ka7kjybdo0jse Note: The cloud only returns logs for DPs in the "official" DPS list. If the device specifications are wrong then not all logs will be returned! This is a limitation of Tuya's se...
def getdevicelog(self, deviceid=None, start=None, end=None, evtype=None, size=0, max_fetches=50, start_row_key=None, params=None): """ Get the logs for a device. https://developer.tuya.com/en/docs/cloud/0a30fc557f?id=Ka7kjybdo0jse Note: The cloud only returns logs for DPs in the "official" DPS list. ...
(self, deviceid=None, start=None, end=None, evtype=None, size=0, max_fetches=50, start_row_key=None, params=None)
[ -0.019734373316168785, 0.006237541325390339, -0.033143628388643265, 0.03168398514389992, 0.015170556493103504, -0.0032014837488532066, -0.05990375205874443, -0.012436158955097198, -0.0771469995379448, -0.027596984058618546, -0.02097993530333042, 0.02203087881207466, 0.01761302538216114, -0...
729,388
tinytuya.Cloud
getdevices
Return dictionary of all devices. If verbose is true, return full Tuya device details.
def getdevices(self, verbose=False, oldlist=[], include_map=False): """ Return dictionary of all devices. If verbose is true, return full Tuya device details. """ old_devices = {} if oldlist: for dev in oldlist: dev_id = dev['id'] old_devices[dev_id] = dev ...
(self, verbose=False, oldlist=[], include_map=False)
[ 0.012837565504014492, -0.04242327809333801, -0.059271953999996185, 0.027183067053556442, -0.01932169310748577, -0.008655555546283722, -0.03677354380488396, -0.012435449287295341, 0.012184126302599907, -0.031083596870303154, -0.015712697058916092, -0.04660528898239136, -0.026660315692424774, ...
729,389
tinytuya.Cloud
getdps
Get the specifications including DPS IDs of the device.
def getdps(self, deviceid=None): """ Get the specifications including DPS IDs of the device. """ if not self.token: return self.error if not deviceid: return error_json( ERR_PARAMS, "Missing DeviceID Parameter" ) uri = 'devices/%s/specifications' %...
(self, deviceid=None)
[ 0.02790261246263981, -0.007330347318202257, 0.012313582003116608, -0.04494544863700867, -0.015352566726505756, 0.05349314212799072, -0.0359073169529438, -0.037203483283519745, -0.016368480399250984, 0.02119407430291176, -0.021159043535590172, -0.04942948371171951, -0.050725653767585754, -0...
729,390
tinytuya.Cloud
getfunctions
Get the functions of the device.
def getfunctions(self, deviceid=None): """ Get the functions of the device. """ return self._getdevice('functions', deviceid)
(self, deviceid=None)
[ -0.009321484714746475, -0.025745052844285965, 0.037763964384794235, -0.06378217786550522, 0.015023638494312763, 0.06064086779952049, -0.036364033818244934, 0.0003582518838811666, 0.011839651502668858, 0.009927552193403244, -0.06361144781112671, -0.024806076660752296, -0.009978769347071648, ...
729,391
tinytuya.Cloud
getmapping
null
def getmapping( self, productid, deviceid=None ): # return a mapping for the given product id, or download it from the cloud using a device id # Return value: None on failure, or a dict on success (may be an empty dict if device does not have DPs) if not self.mappings: self.mappings = {} #load_mappi...
(self, productid, deviceid=None)
[ 0.0641632154583931, 0.006048019044101238, -0.04875806346535683, 0.007183775305747986, 0.025631634518504143, -0.016386672854423523, -0.009777786210179329, -0.02778162620961666, 0.074894480407238, -0.007581056095659733, -0.037447240203619, -0.014489071443676949, -0.04161635413765907, 0.05732...
729,392
tinytuya.Cloud
getmappings
null
def getmappings( self, devices ): # get all mappings for all tuya devices # returns a dict with product ids as keys if not self.mappings: self.mappings = {} for dev in devices: try: devid = dev['id'] productid = dev['product_id'] except: # we n...
(self, devices)
[ 0.05478683486580849, -0.009381113573908806, -0.058937352150678635, -0.02726135589182377, -0.02818579040467739, 0.013800472021102905, -0.025563417002558708, -0.07421880960464478, 0.03573218733072281, 0.03373239189386368, -0.04286352917551994, -0.010838511399924755, -0.04305218905210495, 0.0...
729,393
tinytuya.Cloud
getproperties
Get the properties of the device.
def getproperties(self, deviceid=None): """ Get the properties of the device. """ return self._getdevice('specification', deviceid)
(self, deviceid=None)
[ 0.04185531288385391, 0.005790041759610176, 0.01993921771645546, -0.07546226680278778, 0.042741499841213226, 0.010114465840160847, -0.006561195477843285, -0.0430823415517807, 0.015627574175596237, -0.006467463914304972, -0.05862470716238022, -0.0038983726408332586, -0.02822166122496128, 0.0...
729,394
tinytuya.Cloud
getstatus
Get the status of the device.
def getstatus(self, deviceid=None): """ Get the status of the device. """ return self._getdevice('status', deviceid)
(self, deviceid=None)
[ 0.016874011605978012, -0.0253236535936594, -0.0031043800991028547, -0.03339419886469841, 0.07561713457107544, -0.009713297709822655, -0.010783192701637745, -0.002590493531897664, 0.019392898306250572, -0.09185931831598282, -0.08175007998943329, -0.06119461730122566, 0.0008761343779042363, ...
729,395
tinytuya.Cloud
sendcommand
Send a command to the device
def sendcommand(self, deviceid=None, commands=None, uri='iot-03/devices/'): """ Send a command to the device """ if not self.token: return self.error if (not deviceid) or (not commands): return error_json( ERR_PARAMS, "Missing DeviceID and/or Command Parameter...
(self, deviceid=None, commands=None, uri='iot-03/devices/')
[ 0.01955028437077999, -0.004313891287893057, 0.02824130840599537, -0.100244902074337, 0.012060827575623989, -0.004537491127848625, -0.0588676780462265, 0.05760287493467331, 0.0005344369565136731, -0.012187307700514793, -0.006988052744418383, -0.04231679067015648, -0.02829551510512829, 0.011...
729,396
tinytuya.Cloud
setmappings
null
def setmappings( self, mappings ): # sets an initial mapping set so we do not need to download everything if type(mappings) == dict: self.mappings = mappings
(self, mappings)
[ 0.04195878282189369, -0.002104985062032938, -0.026087721809744835, -0.02813105471432209, -0.062392108142375946, 0.037026599049568176, -0.03330984711647034, 0.026827549561858177, -0.0033952791709452868, 0.03429628163576126, -0.04601021483540535, 0.03614585101604462, -0.002386823995038867, 0...
729,397
tinytuya.Cloud
setregion
null
def setregion(self, apiRegion=None): # Set hostname based on apiRegion if apiRegion is None: apiRegion = self.apiRegion self.apiRegion = apiRegion.lower() self.urlhost = "openapi.tuyacn.com" # China Data Center if self.apiRegion == "us": self.urlhost = "openapi.tuyaus.com" ...
(self, apiRegion=None)
[ -0.009249561466276646, -0.0392070971429348, 0.016115404665470123, -0.011274341493844986, -0.05017772316932678, -0.013464785180985928, -0.0026253110263496637, 0.006166374310851097, -0.03283824399113655, -0.0049192942678928375, -0.0026851340662688017, -0.036151520907878876, 0.00898726098239421...
729,398
tinytuya.CoverDevice
CoverDevice
Represents a Tuya based Smart Window Cover.
class CoverDevice(Device): """ Represents a Tuya based Smart Window Cover. """ DPS_INDEX_MOVE = "1" DPS_INDEX_BL = "101" DPS_2_STATE = { "1": "movement", "101": "backlight", } def open_cover(self, switch=1, nowait=False): """Open the cover""" self.set_s...
(dev_id, address=None, local_key='', dev_type='default', connection_timeout=5, version=3.1, persist=False, cid=None, node_id=None, parent=None, connection_retry_limit=5, connection_retry_delay=5, port=6668)
[ 0.0002544588060118258, -0.07619510591030121, -0.06464064121246338, -0.0006919713923707604, 0.007310974411666393, -0.03224877268075943, -0.06685852259397507, 0.07032844424247742, -0.049115438014268875, -0.005137803964316845, -0.037167470902204514, 0.024343084543943405, 0.0041160560213029385, ...
729,400
tinytuya.core
__init__
Represents a Tuya device. Args: dev_id (str): The device id. address (str): The network address. local_key (str, optional): The encryption key. Defaults to None. cid (str: Optional sub device id. Default to None. node_id (str: alias for cid) ...
def __init__( self, dev_id, address=None, local_key="", dev_type="default", connection_timeout=5, version=3.1, persist=False, cid=None, node_id=None, parent=None, connection_retry_limit=5, connection_retry_delay=5, port=TCPPORT # pylint: disable=W0621 ): """ Represents a Tuya device. Args: d...
(self, dev_id, address=None, local_key='', dev_type='default', connection_timeout=5, version=3.1, persist=False, cid=None, node_id=None, parent=None, connection_retry_limit=5, connection_retry_delay=5, port=6668)
[ 0.0223225187510252, -0.024536818265914917, 0.004625589121133089, 0.013285788707435131, -0.011929281987249851, -0.03135925158858299, -0.07604418694972992, 0.050270553678274155, -0.046041443943977356, -0.08322569727897644, -0.02200334146618843, 0.02667132206261158, -0.005455950740724802, 0.0...
729,419
tinytuya.CoverDevice
close_cover
Close the cover
def close_cover(self, switch=1, nowait=False): """Close the cover""" self.set_status("off", switch, nowait=nowait)
(self, switch=1, nowait=False)
[ 0.017602069303393364, -0.012205208651721478, 0.011258682236075401, 0.032115474343299866, -0.02773156203329563, -0.05416787788271904, -0.01616567373275757, 0.09292564541101456, -0.0007866962696425617, -0.022069009020924568, -0.0670207068324089, -0.014247712679207325, 0.0160826463252306, 0.0...
729,424
tinytuya.CoverDevice
open_cover
Open the cover
def open_cover(self, switch=1, nowait=False): """Open the cover""" self.set_status("on", switch, nowait=nowait)
(self, switch=1, nowait=False)
[ 0.0020542056299746037, -0.040738314390182495, -0.009632948786020279, 0.048774003982543945, 0.031978096812963486, -0.02461753413081169, 0.0040940032340586185, 0.04920213669538498, -0.03500794619321823, 0.00288782618008554, -0.04834587499499321, -0.0020994888618588448, 0.02139008603990078, 0...
729,440
tinytuya.core
set_version
null
def set_version(self, version): # pylint: disable=W0621 self.version = version self.version_str = "v" + str(version) self.version_bytes = str(version).encode('latin1') self.version_header = self.version_bytes + PROTOCOL_3x_HEADER self.payload_dict = None if version == 3.2: # 3.2 behaves like 3.3...
(self, version)
[ 0.030093850567936897, 0.027780352160334587, -0.04116559773683548, 0.0207847710698843, 0.023447131738066673, -0.016699425876140594, -0.0306263230741024, -0.002976794261485338, -0.01019041333347559, 0.018104050308465958, -0.007197553291916847, -0.003750255797058344, -0.05269636958837509, -0....
729,442
tinytuya.CoverDevice
stop_cover
Stop the motion of the cover
def stop_cover(self, switch=1, nowait=False): """Stop the motion of the cover""" self.set_status("stop", switch, nowait=nowait)
(self, switch=1, nowait=False)
[ 0.04048439487814903, 0.01876187138259411, -0.01682414300739765, 0.03358175605535507, -0.04314565286040306, -0.031286418437957764, -0.00605852110311389, 0.08788805454969406, -0.010387224145233631, 0.010944425128400326, -0.07458176463842392, 0.01131034828722477, -0.00003664428004412912, 0.00...
729,444
tinytuya.core
turn_off
Turn the device off
def turn_off(self, switch=1, nowait=False): """Turn the device off""" return self.set_status(False, switch, nowait)
(self, switch=1, nowait=False)
[ 0.030316254124045372, 0.03597752004861832, 0.03825542703270912, -0.014471405185759068, -0.03862391412258148, -0.03755195811390877, -0.0424092561006546, 0.06954314559698105, -0.014253664761781693, -0.018524738028645515, -0.07550589740276337, 0.0038251241203397512, -0.020601654425263405, 0.0...
729,445
tinytuya.core
turn_on
Turn the device on
def turn_on(self, switch=1, nowait=False): """Turn the device on""" return self.set_status(True, switch, nowait)
(self, switch=1, nowait=False)
[ 0.005251491907984018, 0.006180441007018089, 0.020637735724449158, 0.005146880634129047, 0.030295459553599358, -0.011105545796453953, -0.013591112568974495, 0.06015573814511299, -0.02440374530851841, -0.007532020565122366, -0.05660731717944145, -0.016980521380901337, 0.015549438074231148, 0...
729,454
tinytuya.core
Device
null
class Device(XenonDevice): #def __init__(self, *args, **kwargs): # super(Device, self).__init__(*args, **kwargs) def set_status(self, on, switch=1, nowait=False): """ Set status of the device to 'on' or 'off'. Args: on(bool): True for 'on', False for 'off'. ...
(dev_id, address=None, local_key='', dev_type='default', connection_timeout=5, version=3.1, persist=False, cid=None, node_id=None, parent=None, connection_retry_limit=5, connection_retry_delay=5, port=6668)
[ 0.03962932527065277, -0.046639565378427505, -0.02896067686378956, -0.0031449005473405123, 0.018946046009659767, -0.027121255174279213, -0.09507767856121063, 0.03799428418278694, -0.02203218825161457, -0.053343236446380615, -0.06393013149499893, -0.001838144613429904, 0.019038017839193344, ...
729,500
tinytuya.core
MessagePayload
MessagePayload(cmd, payload)
from tinytuya.core import MessagePayload
(cmd, payload)
[ -0.0009237999329343438, -0.053087249398231506, 0.015853451564908028, -0.0044019692577421665, -0.004151986446231604, -0.028488945215940475, -0.05443260818719864, 0.056541554629802704, -0.0027770812157541513, 0.0096902409568429, 0.009481164626777172, 0.01269003376364708, -0.005340540781617165,...
729,502
namedtuple_MessagePayload
__new__
Create new instance of MessagePayload(cmd, payload)
from builtins import function
(_cls, cmd, payload)
[ 0.009963332675397396, -0.03442469611763954, 0.01945531740784645, 0.011539911851286888, 0.012417595833539963, 0.06147034838795662, -0.0007694967789575458, 0.005879666656255722, -0.012458229437470436, -0.02475392445921898, -0.015180673450231552, 0.03676518425345421, 0.006838616915047169, 0.0...
729,505
collections
_replace
Return a new MessagePayload object replacing specified fields with new values
def namedtuple(typename, field_names, *, rename=False, defaults=None, module=None): """Returns a new subclass of tuple with named fields. >>> Point = namedtuple('Point', ['x', 'y']) >>> Point.__doc__ # docstring for the new class 'Point(x, y)' >>> p = Point(11, y=22) #...
(self, /, **kwds)
[ 0.0541859045624733, 0.0014151688665151596, -0.015421349555253983, -0.03568440303206444, -0.032841190695762634, -0.03333566337823868, 0.0027891318313777447, 0.021468330174684525, 0.021015064790844917, -0.04615073278546333, -0.04219495505094528, 0.05707032233476639, 0.004501756746321917, 0.0...
729,506
tinytuya.OutletDevice
OutletDevice
Represents a Tuya based Smart Plug or Switch.
class OutletDevice(Device): """ Represents a Tuya based Smart Plug or Switch. """ def set_dimmer(self, percentage=None, value=None, dps_id=3, nowait=False): """Set dimmer value Args: percentage (int): percentage dim 0-100 value (int): direct value for switch 0-2...
(dev_id, address=None, local_key='', dev_type='default', connection_timeout=5, version=3.1, persist=False, cid=None, node_id=None, parent=None, connection_retry_limit=5, connection_retry_delay=5, port=6668)
[ 0.008266275748610497, -0.05799853056669235, -0.040806904435157776, -0.024135112762451172, -0.015316513366997242, -0.013497097417712212, -0.07002895325422287, 0.03629549592733383, -0.08205938339233398, -0.0026780690532177687, -0.0201435349881649, 0.028609391301870346, -0.016708923503756523, ...
729,534
tinytuya.OutletDevice
set_dimmer
Set dimmer value Args: percentage (int): percentage dim 0-100 value (int): direct value for switch 0-255 dps_id (int): DPS index for dimmer value nowait (bool): True to send without waiting for response.
def set_dimmer(self, percentage=None, value=None, dps_id=3, nowait=False): """Set dimmer value Args: percentage (int): percentage dim 0-100 value (int): direct value for switch 0-255 dps_id (int): DPS index for dimmer value nowait (bool): True to send without waiting for response...
(self, percentage=None, value=None, dps_id=3, nowait=False)
[ 0.0025569009594619274, 0.01954375021159649, -0.007808736525475979, 0.006432786118239164, 0.01054310891777277, 0.031164832413196564, -0.006822784896939993, -0.025363055989146233, -0.023627782240509987, 0.0321464017033577, -0.053740933537483215, 0.024258790537714958, 0.031234946101903915, 0....
729,553
tinytuya.core
TuyaHeader
TuyaHeader(prefix, seqno, cmd, length, total_length)
from tinytuya.core import TuyaHeader
(prefix, seqno, cmd, length, total_length)
[ -0.0454743430018425, -0.04954347386956215, 0.02155926451086998, 0.0011321736965328455, -0.013081904500722885, -0.03051849454641342, -0.05164942890405655, 0.10515495389699936, -0.04925791919231415, 0.005528130568563938, 0.03380235657095909, -0.0034489468671381474, -0.009262630715966225, 0.0...
729,555
namedtuple_TuyaHeader
__new__
Create new instance of TuyaHeader(prefix, seqno, cmd, length, total_length)
from builtins import function
(_cls, prefix, seqno, cmd, length, total_length)
[ 0.009963332675397396, -0.03442469611763954, 0.01945531740784645, 0.011539911851286888, 0.012417595833539963, 0.06147034838795662, -0.0007694967789575458, 0.005879666656255722, -0.012458229437470436, -0.02475392445921898, -0.015180673450231552, 0.03676518425345421, 0.006838616915047169, 0.0...
729,558
collections
_replace
Return a new TuyaHeader object replacing specified fields with new values
def namedtuple(typename, field_names, *, rename=False, defaults=None, module=None): """Returns a new subclass of tuple with named fields. >>> Point = namedtuple('Point', ['x', 'y']) >>> Point.__doc__ # docstring for the new class 'Point(x, y)' >>> p = Point(11, y=22) #...
(self, /, **kwds)
[ 0.0542268380522728, 0.0013855451252311468, -0.015400669537484646, -0.03566362336277962, -0.032861627638339996, -0.03329429030418396, 0.0028251728508621454, 0.021509429439902306, 0.021004658192396164, -0.04615050181746483, -0.04223594814538956, 0.057070039212703705, 0.004481131210923195, 0....
729,559
tinytuya.core
TuyaMessage
TuyaMessage(seqno, cmd, retcode, payload, crc, crc_good, prefix, iv)
from tinytuya.core import TuyaMessage
(seqno, cmd, retcode, payload, crc, crc_good=True, prefix=21930, iv=None)
[ -0.011958115734159946, -0.059560082852840424, 0.030314790084958076, 0.0073021030984818935, -0.007578697521239519, -0.04952891170978546, -0.043997012078762054, 0.0905018225312233, -0.004656012635678053, 0.004969486501067877, 0.01771128736436367, -0.0030471528880298138, -0.008611318655312061, ...
729,561
namedtuple_TuyaMessage
__new__
Create new instance of TuyaMessage(seqno, cmd, retcode, payload, crc, crc_good, prefix, iv)
from builtins import function
(_cls, seqno, cmd, retcode, payload, crc, crc_good=True, prefix=21930, iv=None)
[ 0.009963332675397396, -0.03442469611763954, 0.01945531740784645, 0.011539911851286888, 0.012417595833539963, 0.06147034838795662, -0.0007694967789575458, 0.005879666656255722, -0.012458229437470436, -0.02475392445921898, -0.015180673450231552, 0.03676518425345421, 0.006838616915047169, 0.0...