TPLink Kasa HS200 Connection Refused

  • Platform information:
    • Hardware: Intel i7/16GB RAM/500GB m.2 ssd
    • OS: Win 10 Pro/22H2 64 bit
    • Java Runtime Environment: openjdk version “17.0.13” 2024-10-15 LTS
    • openHAB version: openHAB 4.3.0

Hi All,

This issue is on an existing system running with multiple Kasa HS200 devices which are working without problem. I’ve added another TPLink Kasa HS200 switch which is a newer version: hardware (ver 5.20) and firmware (ver 1.0.3). The Thing adds correctly but it never comes on-line, instead it is failing with a connection refused error. An examination of both the log file and a Wireshark capture of the nic traffic show an issue during initial handshake.

This is the Thing:

UID: tplinksmarthome:hs200:Test14
label: HS200:test14
thingTypeUID: tplinksmarthome:hs200
configuration:
  ipAddress: 192.168.0.14
  refresh: 1
channels:
  - id: switch
    channelTypeUID: system:power
    label: Power
    description: Device is operable when channel has state ON
    configuration: {}
  - id: led
    channelTypeUID: tplinksmarthome:led
    label: Switch Led
    description: Switch the Smart Home device led on or off.
    configuration: {}
  - id: rssi
    channelTypeUID: tplinksmarthome:rssi
    label: Signal
    description: Wi-Fi signal strength indicator.
    configuration: {}

Here is the logfile capture

2024-10-25 19:42:29.862 [DEBUG] [ernal.handler.TPLinkSmartHomeActions] - bundle org.openhab.binding.tplinksmarthome:4.3.0.202410250430 (266)[org.openhab.binding.tplinksmarthome.internal.handler.TPLinkSmartHomeActions(342)] : ServiceFactory.getService()
2024-10-25 19:42:29.863 [DEBUG] [ernal.handler.TPLinkSmartHomeActions] - bundle org.openhab.binding.tplinksmarthome:4.3.0.202410250430 (266)[org.openhab.binding.tplinksmarthome.internal.handler.TPLinkSmartHomeActions(342)] : This thread collected dependencies
2024-10-25 19:42:29.863 [DEBUG] [ernal.handler.TPLinkSmartHomeActions] - bundle org.openhab.binding.tplinksmarthome:4.3.0.202410250430 (266)[org.openhab.binding.tplinksmarthome.internal.handler.TPLinkSmartHomeActions(342)] : getService (ServiceFactory) dependencies collected.
2024-10-25 19:42:29.864 [DEBUG] [ernal.handler.TPLinkSmartHomeActions] - bundle org.openhab.binding.tplinksmarthome:4.3.0.202410250430 (266)[org.openhab.binding.tplinksmarthome.internal.handler.TPLinkSmartHomeActions(342)] : Querying state satisfied
2024-10-25 19:42:29.864 [DEBUG] [ernal.handler.TPLinkSmartHomeActions] - bundle org.openhab.binding.tplinksmarthome:4.3.0.202410250430 (266)[org.openhab.binding.tplinksmarthome.internal.handler.TPLinkSmartHomeActions(342)] : For dependency osgi.ds.satisfying.condition, optional: false; to bind: [[RefPair: ref: [{org.osgi.service.condition.Condition}={service.id=6, service.bundleid=0, service.scope=singleton, service.pid=0.org.osgi.service.condition.ConditionImpl, osgi.condition.id=true}] service: [null]]]
2024-10-25 19:42:29.864 [DEBUG] [ernal.handler.TPLinkSmartHomeActions] - bundle org.openhab.binding.tplinksmarthome:4.3.0.202410250430 (266)[org.openhab.binding.tplinksmarthome.internal.handler.TPLinkSmartHomeActions(342)] : Changed state from satisfied to active
2024-10-25 19:42:29.868 [DEBUG] [me.internal.handler.SmartHomeHandler] - Initializing TP-Link Smart device on ip '192.168.0.14' or deviceId 'null' 
2024-10-25 19:42:30.870 [TRACE] [me.internal.handler.SmartHomeHandler] - Update Channels for:tplinksmarthome:hs200:Test14
2024-10-25 19:42:30.870 [TRACE] [.tplinksmarthome.internal.Connection] - Executing command: {"system":{"get_sysinfo":{}}}
2024-10-25 19:42:33.940 [TRACE] [me.internal.handler.SmartHomeHandler] - Communication error, retry 1
java.net.ConnectException: Connection refused: connect
	at sun.nio.ch.Net.connect0(Native Method) ~[?:?]
	at sun.nio.ch.Net.connect(Net.java:579) ~[?:?]
	at sun.nio.ch.Net.connect(Net.java:568) ~[?:?]
	at sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:593) ~[?:?]
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327) ~[?:?]
	at java.net.Socket.connect(Socket.java:639) ~[?:?]
	at java.net.Socket.connect(Socket.java:588) ~[?:?]
	at java.net.Socket.<init>(Socket.java:512) ~[?:?]
	at java.net.Socket.<init>(Socket.java:292) ~[?:?]
	at org.openhab.binding.tplinksmarthome.internal.Connection.createSocket(Connection.java:102) ~[?:?]
	at org.openhab.binding.tplinksmarthome.internal.Connection.sendCommand(Connection.java:69) ~[?:?]
	at org.openhab.binding.tplinksmarthome.internal.handler.SmartHomeHandler.refreshCache(SmartHomeHandler.java:184) ~[?:?]
	at org.openhab.core.cache.ExpiringCache.refreshValue(ExpiringCache.java:101) ~[?:?]
	at org.openhab.core.cache.ExpiringCache.getValue(ExpiringCache.java:72) ~[?:?]
	at org.openhab.binding.tplinksmarthome.internal.handler.SmartHomeHandler.lambda$3(SmartHomeHandler.java:263) ~[?:?]
	at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
	at org.openhab.binding.tplinksmarthome.internal.handler.SmartHomeHandler.refreshChannels(SmartHomeHandler.java:263) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
	at java.lang.Thread.run(Thread.java:840) [?:?]

It retries four times.

This is an image of a Wireshark capture which basically confirms the connection refusal. This exchange happens first:

And a few tics later this one confirms the refusal. This is repeated for each subsequent retry:

The switch does install correctly in the Kasa app and all switches are accessable from the app. I’ve tried this using the 4.2.2, 4.3.0, and 3.4.5 versions of OH with no difference. I’ve also reduced the variables and configured a test private network containing only the switches, OH server and my router. Also to no avail.

Has anyone else seen this? What am I missing something?

Perplexed,
Reg

I am having the same issue any update?

Jamie, No I haven’t. I did load an instance of Home Assistant and add these devices in the hopes of seeing if there would be a way to make a comparison of the login sequence. I am still investigating, but out of the box, HA worked with all the switches and devices I have.