Add Support for RE270K and RE370K to TP-Link Cloud Connect Service Manager and TP-Link Device Handlers

I am new to SmartThings and this community. I am slowly but surely learning how all of this works. I did implement DaveGut’s Cloud Connect for TP-switches and it works great. His instructions were perfect for a novice like me.

TP-has 2 (maybe more) Wi-Fi extenders with smart plugs built-in that work like a typical HS100. I currently have a RE270K setup and there’s a RE370K on it’s way from Amazon that should arrive within the next few days. They are obviously not as popular as a typical smart plug and not included in the list of supported TP-Link plugs so, although they work in Kasa, they don’t integrate with SmartThings. With the little I know about development, It seems to me though that it should not be any different to implement than the other switches and plugs with no energy monitoring capability.

I’m hoping DaveGut could add them to his Cloud Connect Service Manger and Device handler.

I have added the two devices to the Service Manager as RE270 and RE370. The device handler file is: “TP-Link Plug.groovy”. Please turn on live logging before attempting. I am not sure this will work. I hope it does and I want to know either way.

Dave

1 Like

Thanks for your help with this. A couple of newbie questions:

To update Service Manager, do I just copy over the new code to my and save it? Do I have to publish it?

I’ve been using TP-Link Plug Switch groovy until now. I presume I will have to implement both TP-Link Plug groovy and TP-Link Switch groovy instead.

Is that correct?

Just copy the new code over the old in the smart app. Do a save and publish (for me).

I did what you said. I had a few issues.

  1. I stayed with the Plug switch device handler rather than the plug device handler.
  2. The only option I was given was to publish for me after i saved the modified Service Manager. I didn’t know how to change it to publish for you.
  3. I was able to select the RE270K.
  4. However it did not appear in my list of things.
  5. Live logging showed one error which is not a surprise:

71c80655-f13b-4d1b-ae48-3abd980da664 8:24:59 AM: debug Error Adding null: physicalgraph.app.exception.UnknownDeviceTypeException: Device type ‘TP-Link Smart Plug’ in namespace ‘davegut’ not found

I guess that shouldn’t be a surprise.

“I stayed with the Plug switch device handler”

This indicates that you installed a non-current version of the device handlers. Uninstall the SmartApp and then go to the GitHub site below. It contains the current code. Additionally, the instructions were updated several days ago and are fairly step-by-step. The code and the instructions already incorporate the range extenders (based on your querry).

AFTER you have reinstalled, if you are still having problems, do the following to get me data.

  1. Open the IDE and select “My Locations”. Select your hub.
  2. Select the “List SmartApps” from the line “installed SmartApps”
  3. Select “TP-Link SmartThings Manager” from the group “Other” at the bottom.
  4. Copy the Value field from “Application State” - “devices”.
  5. Paste that data to this forum.

Dave

I did what you said. The WiFi Extender appears in my devices but when I try to turn on the plug, it doesn’t go past “Waiting”.

This is value from Devices Application state:
{50C7BF002F0D={alias=Living Room, appServerUrl=https://use1-wap.tplinkcloud.com, deviceIP=, deviceId=800639DDCBB0E199168D52A9705C1D7916C52564, deviceModel=HS100, deviceNetworkId=50C7BF002F0D, plugId=}, 50C7BF5F6493={alias=Night Lamp, appServerUrl=https://use1-wap.tplinkcloud.com, deviceIP=, deviceId=80069FE3C97D311FCF83C34D2AD780D01871C93C, deviceModel=HS105, deviceNetworkId=50C7BF5F6493, plugId=}, 50C7BF8D68B4={alias=Dining Room Lights, appServerUrl=https://use1-wap.tplinkcloud.com, deviceIP=, deviceId=80063260E1F47A41369FCA66ABD1E058188E089C, deviceModel=HS200, deviceNetworkId=50C7BF8D68B4, plugId=}, 50C7BFA98B3E={alias=tp-link spare mini plug, appServerUrl=https://use1-wap.tplinkcloud.com, deviceIP=, deviceId=80065A0804538F4CD9DBC9169D980817189C1248, deviceModel=HS105, deviceNetworkId=50C7BFA98B3E, plugId=}, 50C7BFCFFD10={alias=Wi-Fi Extender Plug, appServerUrl=https://use1-wap.tplinkcloud.com, deviceIP=, deviceId=8017E17FE4D1F90DF92284706F53F21118B3CC35, deviceModel=RE270, deviceNetworkId=50C7BFCFFD10, plugId=}, 704F57FD7C77={alias=Bedroom Lights, appServerUrl=https://use1-wap.tplinkcloud.com, deviceIP=, deviceId=80066E0E5E96CF14B630B721EFDDCBF6195048A3, deviceModel=HS200, deviceNetworkId=704F57FD7C77, plugId=}}

That probably means that the command structure is different than the devices I am familiar with. That was the reason I had not yet added. Give me a while to check if I can find out the command structure and generate a new handler.

If you are willing, I can send you some instrumentation code and instructions. It may allow me to attempt to see what is being returned from the extender’s plug.

Dave

1 Like

I’m happy to help. Aside from the benefit of possibly getting the plug working I also am learning a lot from this process.

Phil from my phone.

I assume the RE270 is installed, just not controllable. Below is the code to add as a NEW device handler. Do not overwrite the existing DH. After doing that and selecting “publish”:

  1. go to the “My Devices” page.
  2. select your RE270 or 230 device.
  3. at the bottom, select Edit.
  4. at the “Type*” pull-down, select this DH (“RE270/370 TEST”)
  5. select update.
  6. Open live logging
  7. Open the device in your phone app.
  8. Select on/off (need it just once).

You should see a log.debug in your live logging window. That is the data I need.

What am I doing: I am sending a status command to the device that is common to the plugs and bulbs. If this works, it will give me some idea of how to control your RE270. If we get a response, there is a decent chance. If not, I will definitely be at a stop until more information is received.

/*
TEST Code
*/
metadata {
	definition (name: "RE270/370 TEST", 
    			namespace: "davegut", 
                author: "Dave Gutheinz", 
                ocfDeviceType: "oic.d.smartplug", 
                mnmn: "SmartThings", 
                vid: "generic-switch") {
		capability "switch"
	}
	tiles(scale: 2) {
		multiAttributeTile(name: "switch", type: "lighting", width: 6, height: 4, canChangeIcon: true){
			tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
				attributeState "on", label:"test", action: "switch.off", icon: "st.Appliances.appliances17", 
                	backgroundColor: "#00a0dc", nextState: "off"
				attributeState "off", label:"test", action: "switch.on", icon: "st.Appliances.appliances17",
                	backgroundColor: "#ffffff", nextState: "on"
			}
		}
		main("switch")
		details("switch")
	}
	preferences {
	}
}
def installed() {
}
def updated() {
}
def on() {
	sendCmdtoServer('{"system" :{"get_sysinfo" :{}}}')
}
def off() {
	sendCmdtoServer('{"system" :{"get_sysinfo" :{}}}')
}
private sendCmdtoServer(command){
	def appServerUrl = getDataValue("appServerUrl")
	def deviceId = getDataValue("deviceId")
	def cmdResponse = parent.sendDeviceCmd(appServerUrl, deviceId, command)
	String cmdResp = cmdResponse.toString()
	log.debug cmdResp
}
def setAppServerUrl(newAppServerUrl) {
	updateDataValue("appServerUrl", newAppServerUrl)
}
def setAppVersion(appVersion) {
	updateDataValue("appVersion", appVersion)
    updateDataValue("deviceVersion", devVer())
}
//end-of-file

Good data. fair chance of test control dh tomorrow and formal this weekend.

When you ran earlier today (and got the “waiting” status, did the plug power on and off?

No, I don’t believe it did. The green light indicating the plug is active stayed on the whole time. With the plug’s green light on, I tested it in Kasa and there was a discernable click when the plug is toggled. No click and only a green waiting icon using ST. It’s also my main WiFi extender and the connection didn’t waver.

Phil

Philip Share

Home Office: 514-331-6343

Home: 514-333-4124

Cell: 514-267-4154

share.philip@gmail.com

I’m responding here because the forum won’t let me reswpond to your last message.

Log:

6d7c958d-616b-4d4e-999e-5607478c4883 7:07:30 PM: error groovy.lang.MissingPropertyException: No such property: system for class: java.lang.String
Possible solutions: bytes @line 99 (sendCmdtoServer)
6d7c958d-616b-4d4e-999e-5607478c4883 7:07:29 PM: debug {system={err_code=-1, err_msg=module not support}}
6d7c958d-616b-4d4e-999e-5607478c4883 7:06:07 PM: error groovy.lang.MissingPropertyException: No such property: system for class: java.lang.String
Possible solutions: bytes @line 99 (sendCmdtoServer)

I see I only sent you the log of 2 actions. However, all 3 resulted in the same error.

1 Like

The log looks cleaner but switch didn’t actually respond by switching on or off.

6d7c958d-616b-4d4e-999e-5607478c4883 7:40:24 PM: debug Success. onOffState = OFF
6d7c958d-616b-4d4e-999e-5607478c4883 7:40:24 PM: info sendCmdtoServer: {“system” :{“get_sysinfo” :{}}}
65f06918-0dad-4a1f-a64d-adbc3b3e9aca 7:40:24 PM: info TP-Link SmartThings Manager did not find any errors.
52278fbf-4257-4611-9aee-ea9a6744fd68 7:39:14 PM: info HS200 Dining Room Lights: Power: off
6d7c958d-616b-4d4e-999e-5607478c4883 7:38:40 PM: debug Success. onOffState = ON
6d7c958d-616b-4d4e-999e-5607478c4883 7:38:40 PM: info sendCmdtoServer: {“system” :{“get_sysinfo” :{}}}
6d7c958d-616b-4d4e-999e-5607478c4883 7:38:40 PM: debug {system={err_code=-1, err_msg=module not support}}
6d7c958d-616b-4d4e-999e-5607478c4883 7:38:40 PM: info sendCmdtoServer: {“system” :{“set_relay_status” :{“status” : “OFF”}}}
6d7c958d-616b-4d4e-999e-5607478c4883 7:38:40 PM: info sendCmdtoServer: {“system” :{“set_relay_status” :{“status” : “OFF”}}}
6d7c958d-616b-4d4e-999e-5607478c4883 7:38:30 PM: debug Success. onOffState = ON
6d7c958d-616b-4d4e-999e-5607478c4883 7:38:30 PM: info sendCmdtoServer: {“system” :{“get_sysinfo” :{}}}
6d7c958d-616b-4d4e-999e-5607478c4883 7:38:30 PM: debug {system={err_code=-1, err_msg=module not support}}
6d7c958d-616b-4d4e-999e-5607478c4883 7:38:30 PM: info sendCmdtoServer: {“system” :{“set_relay_status” :{“status” : “ON”}}}
6d7c958d-616b-4d4e-999e-5607478c4883 7:38:30 PM: info sendCmdtoServer: {“system” :{“set_relay_status” :{“status” : “ON”}}}
155edeb2-cf26-44cc-a581-66c5e225b349 7:38:18 PM: info HS100 Living Room: Power: on
5d1e0021-0bf1-470c-859f-8511f155700f 7:38:00 PM: debug Outgoing: [requestId:10819563447126297832, payload:[devices:[16d9aa02-4542-4750-8533-4f9203cf38e5:[online:true, on:false], b6524af6-36a3-45a2-879c-32050ad34fd8:[online:true, on:true], a3cfdb14-8562-4fca-b9cd-b04e7e32eaa3:[online:true, on:false]]]]

I will evaluate in the AM and update test code for some other tests. The issue is the exact language for the on/off command. It is different than the plug; however, I believe we are close. I do know that the command name is not “set_relay_status”. Testing tomorrow (one run) will test the some other likely options. (Without the actual firmware, this is the best I can do.)

Just noticed in logs. It includes the following lines:
6d7c958d-616b-4d4e-999e-5607478c4883 7:38:30 PM: debug Success. onOffState = ON

6d7c958d-616b-4d4e-999e-5607478c4883 7:40:24 PM: debug Success. onOffState = OFF

The only way for this to happen is for the command to actually work. Will focus testing tomorrow.

Didn’t work.

f022d832-4b61-4957-b34e-cd94af578082 4:22:10 AM: trace Notify: BinaryState = off
f022d832-4b61-4957-b34e-cd94af578082 4:22:10 AM: debug Parsing ‘index:7A, mac:14918247C649, headers:Tk9USUZZIC8gSFRUUC8xLjENCkhPU1Q6IDE5Mi4xNjguMC44OjM5NTAwDQpDT05URU5ULVRZUEU6IHRleHQveG1sOyBjaGFyc2V0PSJ1dGYtOCINCkNPTlRFTlQtTEVOR1RIOiAxMzINCk5UOiB1cG5wOmV2ZW50DQpOVFM6IHVwbnA6cHJvcGNoYW5nZQ0KU0lEOiB1dWlkOmQ5NzM1ZmI4LTFkZDEtMTFiMi05MDc3LWFlODRjZDc3YmE3Ng0KU0VROiAw, body:PGU6cHJvcGVydHlzZXQgeG1sbnM6ZT0idXJuOnNjaGVtYXMtdXBucC1vcmc6ZXZlbnQtMS0wIj4KPGU6cHJvcGVydHk+CjxCaW5hcnlTdGF0ZT4wPC9CaW5hcnlTdGF0ZT4KPC9lOnByb3BlcnR5Pgo8L2U6cHJvcGVydHlzZXQ+CgoN’
f022d832-4b61-4957-b34e-cd94af578082 4:22:10 AM: debug Parsing ‘index:79, mac:14918247C649, ip:C0A80027, port:C001, requestId:c44ba217-1380-411f-8783-6383f62ecea0, headers:SFRUUC8xLjEgMjAwIE9LDQpEQVRFOiBGcmksIDAxIEZlYiAyMDE5IDA5OjIyOjA5IEdNVA0KU0VSVkVSOiBVbnNwZWNpZmllZCwgVVBuUC8xLjAsIFVuc3BlY2lmaWVkDQpDT05URU5ULUxFTkdUSDogMA0KWC1Vc2VyLUFnZW50OiByZWRzb25pYw0KU0lEOiB1dWlkOmQ5NzM1ZmI4LTFkZDEtMTFiMi05MDc3LWFlODRjZDc3YmE3Ng0KVElNRU9VVDogU2Vjb25kLTU0MDA=, body:’
f022d832-4b61-4957-b34e-cd94af578082 4:22:10 AM: debug Using ip: C0A80027 and port: C001 for device: f022d832-4b61-4957-b34e-cd94af578082
f022d832-4b61-4957-b34e-cd94af578082 4:22:10 AM: debug Executing ‘resubscribe()’
6d7c958d-616b-4d4e-999e-5607478c4883 4:21:59 AM: error I think we failed
6d7c958d-616b-4d4e-999e-5607478c4883 4:21:59 AM: debug {system={err_code=-1, err_msg=module not support}}
6d7c958d-616b-4d4e-999e-5607478c4883 4:21:59 AM: info sendCmdtoServer: {“system” :{“set_relay_status” :{“status” : “OFF”}}}
6d7c958d-616b-4d4e-999e-5607478c4883 4:21:59 AM: info sendCmdtoServer: {“system” :{“set_relay_status” :{“status” : “OFF”}}}
6d7c958d-616b-4d4e-999e-5607478c4883 4:21:36 AM: error I think we failed
6d7c958d-616b-4d4e-999e-5607478c4883 4:21:36 AM: debug {system={err_code=-1, err_msg=module not support}}
6d7c958d-616b-4d4e-999e-5607478c4883 4:21:36 AM: info sendCmdtoServer: {“system” :{“set_relay_status” :{“status” : “ON”}}}
6d7c958d-616b-4d4e-999e-5607478c4883 4:21:36 AM: info sendCmdtoServer: {“system” :{“set_relay_status” :{“status” : “ON”}}}
4:21:26 AM: info Waiting on events…

I tried your latest change. Wh3en I did so, the ST button said REFRESH. What I did was uninstall the WiFi Extender and then install it again. The refresh went away. When I tried to use it, it went back to a persistent green “WAITING” state.

6d7c958d-616b-4d4e-999e-5607478c4883 11:01:32 AM: error commandResponse failed with errorCode = -1/module not support
6d7c958d-616b-4d4e-999e-5607478c4883 11:01:32 AM: info commandResponse: errorCode = -1, errorMsg = module not support
6d7c958d-616b-4d4e-999e-5607478c4883 11:01:32 AM: debug {system={err_code=-1, err_msg=module not support}}
6d7c958d-616b-4d4e-999e-5607478c4883 11:01:31 AM: info Version 4 sendCmdtoServer: {“system”:{“set_relay_status”:{“status”:“OFF”}}}
6d7c958d-616b-4d4e-999e-5607478c4883 11:01:22 AM: error commandResponse failed with errorCode = -1/module not support
6d7c958d-616b-4d4e-999e-5607478c4883 11:01:22 AM: info commandResponse: errorCode = -1, errorMsg = module not support
6d7c958d-616b-4d4e-999e-5607478c4883 11:01:22 AM: debug {system={err_code=-1, err_msg=module not support}}
6d7c958d-616b-4d4e-999e-5607478c4883 11:01:15 AM: info Version 4 sendCmdtoServer: {“system”:{“set_relay_status”:{“status”:“ON”}}}