plasticrake / homebridge-tplink-smarthome

TP-Link Smarthome Plugin for Homebridge
MIT License
474 stars 70 forks source link

Manual Definition of Plugs/Bulbs #38

Closed JohnRuddy closed 7 years ago

JohnRuddy commented 7 years ago

I think I saw in an older version a config where you can manually define instances of plugs based on their IP addresses and port number (9999).

Is this still possible as autodiscover is not an option for me with my router

pi@raspberrypi:~/.homebridge $ homebridge --debug WARNING The program 'node' uses the Apple Bonjour compatibility layer of Avahi. WARNING Please fix your application to use the native API of Avahi! WARNING For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=node WARNING The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi. WARNING Please fix your application to use the native API of Avahi! WARNING For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister [10/21/2017, 4:10:07 PM] Loaded plugin: homebridge-hs100 [10/21/2017, 4:10:07 PM] Registering platform 'homebridge-hs100.Hs100' [10/21/2017, 4:10:07 PM] --- [10/21/2017, 4:10:07 PM] Loaded plugin: homebridge-platform-energenie [10/21/2017, 4:10:07 PM] Registering platform 'homebridge-platform-energenie.Energenie' [10/21/2017, 4:10:07 PM] --- [10/21/2017, 4:10:07 PM] Loaded plugin: homebridge-tplink-lightbulb [10/21/2017, 4:10:07 PM] Registering platform 'homebridge-tplink-lightbulb.TplinkLightbulb' [10/21/2017, 4:10:07 PM] --- [10/21/2017, 4:10:08 PM] Loaded plugin: homebridge-tplink-smarthome [10/21/2017, 4:10:08 PM] Registering platform 'homebridge-tplink-smarthome.TplinkSmarthome' [10/21/2017, 4:10:08 PM] --- [10/21/2017, 4:10:08 PM] Loaded config.json with 0 accessories and 2 platforms. [10/21/2017, 4:10:08 PM] --- [10/21/2017, 4:10:08 PM] Loading 2 platforms... [10/21/2017, 4:10:08 PM] [TplinkSmarthome] Initializing TplinkSmarthome platform... [10/21/2017, 4:10:08 PM] [TplinkSmarthome] homebridge-tplink-smarthome v3.8.0, node v6.5.0, homebridge v0.4.28 [10/21/2017, 4:10:08 PM] [TplinkSmarthome] config.json: {"platform":"TplinkSmarthome","name":"TplinkSmarthome","plugs":[{"name":"Hallway Light","host":"192.168.0.115","port":9999}],"bulbs":[{"name":"Double Bedroom","host":"192.168.0.241","port":9999}],"switchModels":["HS200","HS100","LB110"],"deviceTypes":["plug","bulb"]} [10/21/2017, 4:10:08 PM] [TplinkSmarthome] config: {"platform":"TplinkSmarthome","name":"TplinkSmarthome","plugs":[{"name":"Hallway Light","host":"192.168.0.115","port":9999}],"bulbs":[{"name":"Double Bedroom","host":"192.168.0.241","port":9999}],"switchModels":["HS200","HS100","LB110"],"deviceTypes":["plug","bulb"],"addCustomCharacteristics":true,"discoveryOptions":{"discoveryInterval":10000,"deviceTypes":["plug","bulb"],"deviceOptions":{"timeout":5000}}} [10/21/2017, 4:10:08 PM] [Energenie Platform] Initializing Energenie platform... [10/21/2017, 4:10:08 PM] [Energenie Platform] Initializing platform accessory 'Kitchen Lamp'... [10/21/2017, 4:10:08 PM] [Energenie Platform] Initializing platform accessory 'Living Room Small Lamp'... Load homebridge-hs100.Hs100 [10/21/2017, 4:10:08 PM] [homebridge-hs100.Hs100] homebridge-hs100 v3.7.0, node v6.5.0, homebridge v0.4.28 [10/21/2017, 4:10:08 PM] [homebridge-hs100.Hs100] config.json: null [10/21/2017, 4:10:08 PM] [homebridge-hs100.Hs100] config: {"deviceTypes":[],"addCustomCharacteristics":true,"switchModels":["HS200"],"discoveryOptions":{"discoveryInterval":10000,"deviceTypes":[],"deviceOptions":{"timeout":5000}}} Load homebridge-tplink-lightbulb.TplinkLightbulb Scan this code with your HomeKit App on your iOS device to pair with Homebridge:

┌────────────┐
│ 031-45-154 │
└────────────┘

[10/21/2017, 4:10:08 PM] [TplinkSmarthome] didFinishLaunching [10/21/2017, 4:10:08 PM] [TplinkSmarthome.API] client.startDiscovery({"discoveryInterval":10000,"deviceTypes":["plug","bulb"],"deviceOptions":{"timeout":5000}}) [10/21/2017, 4:10:08 PM] [homebridge-hs100.Hs100] didFinishLaunching [10/21/2017, 4:10:08 PM] [homebridge-hs100.Hs100.API] client.startDiscovery({"discoveryInterval":10000,"deviceTypes":[],"deviceOptions":{"timeout":5000}}) [10/21/2017, 4:10:08 PM] Homebridge is running on port 51826. [10/21/2017, 4:10:08 PM] [TplinkSmarthome.API] client.socket: UDP IPv4 listening on 0.0.0.0:38563 [10/21/2017, 4:10:08 PM] [TplinkSmarthome.API] client.sendDiscovery("255.255.255.255") [10/21/2017, 4:10:08 PM] [homebridge-hs100.Hs100.API] client.socket: UDP IPv4 listening on 0.0.0.0:55632 [10/21/2017, 4:10:08 PM] [homebridge-hs100.Hs100.API] client.sendDiscovery("255.255.255.255") [10/21/2017, 4:10:18 PM] [TplinkSmarthome.API] client.sendDiscovery("255.255.255.255") [10/21/2017, 4:10:18 PM] [homebridge-hs100.Hs100.API] client.sendDiscovery("255.255.255.255")

plasticrake commented 7 years ago

What is it about your router that discovery doesn't work? Does that TP-Link Kasa app not work either?

JohnRuddy commented 7 years ago

TPLink Kasa works just fine. In a previous version I was able to create a manual definition of a plug HS100 with IP and port number. I've been able to turn the lights on and off using the tplights utility providing it the IP & port of the bulb.

The router is a locked down Virgin Media one. I've since tinkered with the broadcast ports 255.255.255.255 and 192.168.0.255 to no avail.

In my situation I think defining the plugs manually with IP addresses in the cachedAccessories would probably be an adequate work around given my circumstances and unique situation. I just need to know what a cachedAccessory definition looks like and whether it holds a variable for IP address.

plasticrake commented 7 years ago

Hmm, yeah I was going to suggest changing to a directed broadcast like "192.168.0.255" but sounds like you've tried that.

Adding to the cachedAccessories like that won't really work as this plugin uses the broadcast to update the status. The underlying API I wrote does support targeting individual devices and not relying on the broadcast, but I'll have to make this plugin work with that configuration. I'll update this issue when I have something ready.

plasticrake commented 7 years ago

New version has a devices configuration you can try. Let me know if that solves your problem

JohnRuddy commented 7 years ago

Superb, Works perfectly!