TP-Link devices on different networks

So I updated to 89.0 and my TP-Link devices stopped working.

Apparently setting them up in the config file is no longer possible. Instead it now requires using the built-in TP-Link Integration control panel to configure them.

Clicking that option performs a scan of my network but doesn’t return any devices. That’s expected because ALL my TP-link devices are at different locations and on different networks. I “was” using them to remotely control lights at different houses over the internet.

Is there anyway to override the built-in scanning behavior so I can go back to using my own IP addresses??

Still supported in the configuration.yaml, remove the switch platform config and replace with

tplink:
  discovery: false
  switch:
    - host: 192.168.10.167
    - host: 192.168.10.172
    - host: 192.168.10.176

More here,

I think if you look at the individual Tplink pages, it still references the old way of doing it.

3 Likes

You’re right, I think the old references should be removed because it will surely confused people. I only knew of the new way to define it by reading the 89 breaking changes post which had tagged the link to the updated documentation

I had a custom scan interval on one switch but with the new way of doing things, I get an invalid config error when I add a custom scan_interval in the config:

tplink:
  switch:
    - host: 192.168.2.120
    - host: 192.168.2.121
      scan_interval: 15

I get the following message in log file:

2019-03-07 21:19:15 ERROR (MainThread) [homeassistant.config] Invalid config for [tplink]: [scan_interval] is an invalid option for [tplink]. Check: tplink->tplink->switch->1->scan_interval. (See c:\ProgramData\.homeassistant\configuration.yaml, line 93). Please check the docs at https://home-assistant.io/components/tplink/

Any ideas?

Yeah I had the same issue, they’ve linked the old doco in the breaking change.

Thanks, that was the solution. Indeed I was tripped up by consulting the old docs.

Same here. Had defined the scan_interval as well as enable_leds parameters but they both don’t work anymore.

How can I add custom icon to these entries?

How can I add a name?

Hello, could you explain how you define a TP Link switch on a remote LAN through internet (how do you code the IP address ? Is it the local IP address of the TP-Link on the remote LAN ?.. Do you use NAT on the other site by bridging an external port to the local IP address ?) Maybe give us some examples. Thank you in advance for your help…

Normally in the configuration.yaml you’d use the devices internal address i.e. 192.168.1.29.
Since the device is at a remote location I just used the remote locations external IP address instead.
On the remote locations router I used port forwarding to forward PORT 9999 to the devices LAN IP.

Note that doing this method only allows one device at each remote location, which is all I needed in my case. That’s because you can only port forward port 9999 to one device. I don’t see any way of setting TP-link devices to listen on different ports which would allow more than one. If you are adventurous you could probably setup a reverse proxy on the remote side and use hostnames to forward to multiple different devices.

Thank you for these explanations… I will try this solution with one TP Link HS100 on a remote location…

Another option which does not require port forwarding and works with as many HS100s on as many remote networks as you’d like is to create a command_line switch for each one that takes advantage of the TP-Link cloud API. Your devices must first be registered with the Kasa app for this to work. Once registered, it is not necessary to use the app.

Here’s an example command_line switch:

- platform: command_line
  switches:
    los_ficus_boiler:
      command_on: >-
          curl --request POST https://eu-wap.tplinkcloud.com/?token=YOUR_TOKEN --data '{"method":"passthrough","params":{"deviceId":"YOUR_DEVICE_ID","requestData":"{\"system\":{\"set_relay_state\":{\"state\":1}}}"}}' --header "Content-Type:application/json"
      command_off: >-
          curl --request POST https://eu-wap.tplinkcloud.com/?token=YOUR_TOKEN --data '{"method":"passthrough","params":{"deviceId":"YOUR_DEVICE_ID","requestData":"{\"system\":{\"set_relay_state\":{\"state\":0}}}"}}' --header "Content-Type:application/json"
      command_state: >-
          curl -s --request POST https://wap.tplinkcloud.com/?token=YOUR_TOKEN --data '{"method":"passthrough","params":{"deviceId":"YOUR_DEVICE_ID","requestData":"{\"system\":{\"get_sysinfo\":null},\"emeter\":{\"get_realtime\":null}}"}}' --header "Content-Type:application/json"
      value_template: "{{ (value_json.result.responseData.split('relay_state\":')[1][0]) == '1' }}"
      friendly_name: Los Ficus Boiler

You’ll need to get a token and retrieve your device IDs and end point URLs. @adumont has written up great guides for that.

To get a TP-Link token, follow this guide: Get Token

To get endpoint URLs and device IDs, follow this guide: Endpoints & device IDs

Do pay attention to the device endpoint URLs. They appear to differ from region to region. Note that in the example above, even though the on and off commands use eu-wap.tplinkcloud.com, the get-state command omits the eu- as in wap.tplinkcloud.com.

3 Likes

Hi Thanks for the tip , the curl command works perfect for turning it on and off but I can’t get the state …

Error parsing value: list object has no element 1

Any ideas ?