plasticrake / homebridge-tplink-smarthome

TP-Link Smarthome Plugin for Homebridge
MIT License
468 stars 69 forks source link

Auto Discovery for HS100 plugs not working #55

Closed ajorpheus closed 6 years ago

ajorpheus commented 6 years ago

Expected Behavior

When homebridge starts it should discover the existing plugs on the network.

Current Behavior

Two plugs configured and working in the Kasa mobile application are not discovered. I have already tried deleting the cached and persisted accessories. Everything was working fine till a couple of days back when the plugs stopped responding from the 'Home' app on the phone.

Things I have tried

As in a similar issue (#47) , I have tried the following with no joy:

Steps to Reproduce (for bugs)

Versions

Configuration

    "platforms": [{
        "platform": "TplinkSmarthome",
        "name": "TplinkSmarthome",
        "devices": [
            { "host": "192.168.1.96" },
            { "host": "192.168.1.98" }
        ]
    }]

OR,

    "platforms": [{
        "platform": "TplinkSmarthome",
        "name": "TplinkSmarthome"
    }]

Homebridge Log / Command Output

Besides the output of homebridge below, this might be useful as well (as I recall you asking for this in another issue):

$ tplink-smarthome-api search
Searching...
startDiscovery({ discoveryInterval: 2000, discoveryTimeout: 5000 })

With either version of the config.json above:

$ homebridge
[27/02/2018, 10:46:22] Loaded plugin: homebridge-tplink-smarthome
[27/02/2018, 10:46:22] Registering platform 'homebridge-tplink-smarthome.TplinkSmarthome'
[27/02/2018, 10:46:22] ---
[27/02/2018, 10:46:22] Loaded config.json with 0 accessories and 1 platforms.
[27/02/2018, 10:46:22] ---
[27/02/2018, 10:46:22] Loading 1 platforms...
[27/02/2018, 10:46:22] [TplinkSmarthome] Initializing TplinkSmarthome platform...
[27/02/2018, 10:46:22] [TplinkSmarthome] homebridge-tplink-smarthome v3.11.0, node v9.4.0, homebridge v0.4.38
Setup Payload:
X-HM://0023HO8UXD31P
Scan this code with your HomeKit app on your iOS device to pair with Homebridge:
<redacted>
Or enter this code with your HomeKit app on your iOS device to pair with Homebridge:
<redacted>
[27/02/2018, 10:46:22] Homebridge is running on port 51826.

(Off-topic : The issue template is quite nice 👍 )

henrik commented 6 years ago

I have a similar (?) issue where my plugs worked fine. Then I installed the Nest plugin and restarted Homebridge. Now it does not discover the plugs, even if I remove the Nest config from config.json again.

EDIT: Restarting the router seemed to fix it.

plasticrake commented 6 years ago

@ajorpheus I've heard reports of some routers not handling the UDP broadcast packets appropriately. What happens if you try to address the plugs directly?

For Example:

$ tplink-smarthome-api getSysInfo 192.168.1.96
henrik commented 6 years ago

I had a similar issue again and it was again fixed by restarting my router, I believe. It's a Huawei router from UK broadband provider TalkTalk.

I think it started as the Home app showing the accessories, but tapping them had no effect. Restarting homebridge would show "Configuring cached accessory: [Fairy Lights] …" but it still would not work.

Removing ~/.homebridge/accessories/cachedAccessories and then starting homebridge would start it without any accessories.

Restarting the router and then starting Homebridge added the accessories again and now it works.

If it happens again, I'll try a router restart without removing cachedAccessories to see if that saves me from having to re-add the accessories and re-add them to Home automations etc.

ajorpheus commented 6 years ago

@plasticrake , @henrik

Thank you very much. I do not know what the problem was and how it was fixed.

All I did was try installing homebridge from scratch on a laptop (same OS) and it worked fine there. I thought that that meant there was a problem with the original (desktop), however when I went back and checked, everything was working fine there as well!

I do remember fiddling with the router settings to change the WiFi channel settings in order to troubleshoot some latency and throughput issues that I had been having on the LAN. I do not know if 'committing' those settings restarted the router. Also I do not recall if I did this before or after the problem went away.

However, it does seem like a router restart is a very promising thing to try out.

(FWIW, downgrading the node version to a time when everything was working did not have any effect)