├── Images ├── Bulb.png ├── DeviceList.png ├── MainAppPage.png ├── multi-plug.png ├── plug-switch.png ├── EMmulti-plug.png ├── SelectDevices.png ├── preferencesMP.png ├── DevicesToInstall.png └── preferencesNonMP.png ├── README.md └── getTapoData.groovy /Images/Bulb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveGut/Test-Code/HEAD/Images/Bulb.png -------------------------------------------------------------------------------- /Images/DeviceList.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveGut/Test-Code/HEAD/Images/DeviceList.png -------------------------------------------------------------------------------- /Images/MainAppPage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveGut/Test-Code/HEAD/Images/MainAppPage.png -------------------------------------------------------------------------------- /Images/multi-plug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveGut/Test-Code/HEAD/Images/multi-plug.png -------------------------------------------------------------------------------- /Images/plug-switch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveGut/Test-Code/HEAD/Images/plug-switch.png -------------------------------------------------------------------------------- /Images/EMmulti-plug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveGut/Test-Code/HEAD/Images/EMmulti-plug.png -------------------------------------------------------------------------------- /Images/SelectDevices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveGut/Test-Code/HEAD/Images/SelectDevices.png -------------------------------------------------------------------------------- /Images/preferencesMP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveGut/Test-Code/HEAD/Images/preferencesMP.png -------------------------------------------------------------------------------- /Images/DevicesToInstall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveGut/Test-Code/HEAD/Images/DevicesToInstall.png -------------------------------------------------------------------------------- /Images/preferencesNonMP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaveGut/Test-Code/HEAD/Images/preferencesNonMP.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Test code based on user request. 2 | These files are temporary files to support testing as well as temporary capability provision pending final integration. 3 | 4 | 5 | -------------------------------------------------------------------------------- /getTapoData.groovy: -------------------------------------------------------------------------------- 1 | /* Get Tapo Data 2 | Copyright Dave Gutheinz 3 | License: https://github.com/DaveGut/HubitatActive/blob/master/KasaDevices/License.md 4 | polls a specific Tapo device for the initial discovery data. 5 | Instructions 6 | a. Add new driver from Driver Code -> New Driver 7 | 1) Select Import 8 | 2) Copy/enter the following: https://raw.githubusercontent.com/DaveGut/Test-Code/refs/heads/master/getTapoData.groovy 9 | 3) Save Driver 10 | b. Add device from Devices page -> Add Device -> Virtual 11 | 1) Select Device Driver "Get Tapo Discovery Data" (Near bottom of very long list) 12 | 2) Name Device 13 | 3) Skip Device 14 | 4) Get Device Details 15 | c. Open a separate LOG window 16 | d. Enter the Ip Address for your device in the IP preference. 17 | 1) Save preferences 18 | 2) Expected result is a debug message similar to (but not exactly) the below: 19 | [POLLRESP:[device_id:e07fc85b7b19c0510d676d448bzzzzzz, device_model:H100(US), 20 | device_type:SMART.TAPOHUB, factory_default:false, ip:192.168.50.169, 21 | is_support_iot_cloud:true, mac:9C-A2-F4-C3-zz-zz, mgt_encrypt_schm: 22 | [encrypt_type:KLAP, http_port:80, is_support_https:false, lv:2], obd_src:tplink, 23 | owner:0D8E1ED8A10E5D767EAB6EA910zzzzzz, protocol_version:1]] 24 | e. If you need to run again, simply select the command "Get Tapo Data" 25 | send the results to me. You can redact the mac, device_id, and owner values, but none 26 | of the others. 27 | 28 | DEVELOPMENT ONLY 29 | 30 | Get Tapo Discovery Data 31 | =================================================================================================*/ 32 | import groovy.json.JsonSlurper 33 | 34 | metadata { 35 | definition (name: "Get Tapo Discovery Data", namespace: "davegut", author: "Dave Gutheinz", 36 | importUrl: "https://raw.githubusercontent.com/DaveGut/Test-Code/refs/heads/master/getTapoData.groovy") 37 | { 38 | command "getTapoData" 39 | } 40 | preferences { 41 | input ("ip", "string", title: "IP Address of Tapo Device", defaultValue: "notSet") 42 | } 43 | } 44 | 45 | def installed() { 46 | } 47 | def updated() { 48 | if (ip == "notSet") { 49 | logData << [error: "IP NOT SET"] 50 | log.warn(logData) 51 | } else { 52 | runIn(1, getTapoData) 53 | } 54 | } 55 | 56 | def getTapoData() { 57 | Integer port = 20002 58 | def cmdData = "0200000101e51100095c11706d6f58577b22706172616d73223a7b227273615f6b6579223a222d2d2d2d2d424547494e205055424c4943204b45592d2d2d2d2d5c6e4d494942496a414e42676b71686b6947397730424151454641414f43415138414d49494243674b43415145416d684655445279687367797073467936576c4d385c6e54646154397a61586133586a3042712f4d6f484971696d586e2b736b4e48584d525a6550564134627532416257386d79744a5033445073665173795679536e355c6e6f425841674d303149674d4f46736350316258367679784d523871614b33746e466361665a4653684d79536e31752f564f2f47474f795436507459716f384e315c6e44714d77373563334b5a4952387a4c71516f744657747239543337536e50754a7051555a7055376679574b676377716e7338785a657a78734e6a6465534171765c6e3167574e75436a5356686d437931564d49514942576d616a37414c47544971596a5442376d645348562f2b614a32564467424c6d7770344c7131664c4f6a466f5c6e33737241683144744a6b537376376a624f584d51695666453873764b6877586177717661546b5658382f7a4f44592b2f64684f5374694a4e6c466556636c35585c6e4a514944415141425c6e2d2d2d2d2d454e44205055424c4943204b45592d2d2d2d2d5c6e227d7d" 59 | sendLanCmd(ip, port, cmdData, parseLanData) 60 | } 61 | private sendLanCmd(ip, port, cmdData, action, commsTo = 5) { 62 | Map data = [port: port, action: action] 63 | def myHubAction = new hubitat.device.HubAction( 64 | cmdData, 65 | hubitat.device.Protocol.LAN, 66 | [ 67 | type: hubitat.device.HubAction.Type.LAN_TYPE_UDPCLIENT, 68 | destinationAddress: "${ip}:${port}", 69 | encoding: hubitat.device.HubAction.Encoding.HEX_STRING, 70 | parseWarning: true, 71 | timeout: commsTo, 72 | callback: action]) 73 | try { 74 | sendHubCommand(myHubAction) 75 | } catch (error) { 76 | log.warn("sendLanCmd: command failed. Error = ${error}") 77 | } 78 | } 79 | def parseLanData(response) { 80 | log.trace response 81 | def respData = parseLanMessage(response) 82 | byte[] payloadByte = hubitat.helper.HexUtils.hexStringToByteArray(respData.payload.drop(32)) 83 | def payload = new String(payloadByte) 84 | if (payload.length() > 1007) { 85 | payload = payload + """"}}}""" 86 | } 87 | Map pollResp = new JsonSlurper().parseText(payload).result 88 | log.debug([POLLRESP: new JsonSlurper().parseText(payload).result]) 89 | } 90 | 91 | --------------------------------------------------------------------------------