@@ -212,6 +212,48 @@ def test_set_brightness_C(self):
212212 self .assertEqual (result_cmd , expected_cmd )
213213 self .assertDictEqual (result_payload , expected_payload )
214214
215+ def test_set_bulb_type (self ):
216+ d = tinytuya .BulbDevice ('DEVICE_ID_HERE' , 'IP_ADDRESS_HERE' , LOCAL_KEY )
217+ d .status = lambda nowait = False : {"devId" :"DEVICE_ID" ,"dps" :{"1" : False , "2" : 90 }} # tell it which commands to support and which DPs need updating
218+ d .set_bulb_type ('C' ) # tell it which commands to support
219+ d .set_version (3.1 )
220+ d ._send_receive = MagicMock (return_value = {})
221+
222+ # act
223+ d .turn_on ()
224+
225+ # gather results
226+ result_cmd , result_payload = get_results_from_mock (d )
227+
228+ # expectations
229+ expected_cmd = tinytuya .CONTROL
230+ expected_payload = {"dps" :{'1' : True }, "devId" : "DEVICE_ID_HERE" ,"uid" : "DEVICE_ID_HERE" , "t" : "" }
231+
232+ # assert
233+ self .assertEqual (result_cmd , expected_cmd )
234+ self .assertDictEqual (result_payload , expected_payload )
235+
236+ def test_not_a_bulb (self ):
237+ d = tinytuya .BulbDevice ('DEVICE_ID_HERE' , 'IP_ADDRESS_HERE' , LOCAL_KEY )
238+ d .status = lambda nowait = False : {"devId" :"DEVICE_ID" ,"dps" :{"1" : False }} # tell it which commands to support and which DPs need updating
239+ #d.set_bulb_type('C') # tell it which commands to support
240+ d .set_version (3.1 )
241+ d ._send_receive = MagicMock (return_value = {})
242+
243+ # act
244+ d .turn_on ()
245+
246+ # gather results
247+ result_cmd , result_payload = get_results_from_mock (d )
248+
249+ # expectations
250+ expected_cmd = tinytuya .CONTROL
251+ expected_payload = {"dps" :{'1' : True }, "devId" : "DEVICE_ID_HERE" ,"uid" : "DEVICE_ID_HERE" , "t" : "" }
252+
253+ # assert
254+ self .assertEqual (result_cmd , expected_cmd )
255+ self .assertDictEqual (result_payload , expected_payload )
256+
215257
216258if __name__ == '__main__' :
217259 unittest .main ()
0 commit comments