Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

homebridge-tplink-smarthome

plasticrake543MIT8.0.3TypeScript support: included

TPLink Smarthome plugin for Homebridge

homebridge-plugin, homebridge, tplink, kasa, homeautomation, automation, home, smarthome, smartplug, smartswitch, smartbulb

readme

homebridge-tplink-smarthome

NPM Version verified-by-homebridge

TPLink Smart Home Plugin for Homebridge. (formerly homebridge-hs100)

Models Supported

  • Plugs: EP25, EP40, HS100, HS103, HS105, HS107, HS110, HS300, KP105, KP115, KP303, KP400
  • Switches: ES20M, HS200, HS210, HS220, HS230
  • Bulbs: KL50, KL120, KL125, LB100, LB110, LB120, LB130, LB200, LB230
  • Lightstrips: KL400, KL430

More models may be supported than listed. If you have another model working please let me know so I can add here.

Tapo devices are not supported and are out of scope with this plugin.

HomeKit

Model Service Characteristics
HS100, HS103, HS105, HS107, KP105, KP303, KP400 Outlet On
OutletInUse (based on On state)
HS110, HS300, KP115 Outlet On
OutletInUse (based on energy monitoring)
Volts (Custom)
Amperes (Custom)
Watts (Custom)
VoltAmperes (Custom)
KilowattHours (Custom)
KilowattVoltAmpereHour (Custom)
EP25, EP40 Outlet On
OutletInUse (based on On state)
HS200, HS210 Switch On
HS220, HS230 Lightbulb On
Brightness
KL50, LB100, LB110, LB200 Lightbulb On
Brightness
Watts (Custom)
LB120, KL120 Lightbulb On
Brightness
ColorTemperature
Watts (Custom)
KL125, KL400, KL430, LB130, LB230 Lightbulb On
Brightness
ColorTemperature
Hue
Saturation
Watts (Custom)
ES20M Lightbulb On
Brightness

Installation

Manual Installation

  1. Node v18 or greater is required. Check by running: node --version
  2. Install Homebridge: (instructions)
  3. Homebridge v1.6.0 or greater is required. Check by running homebridge --version
  4. Install this plugin using: npm install -g homebridge-tplink-smarthome
  5. Update your configuration file. See the sample below.

Homebridge Config UI X Installation

Check out Homebridge Config UI X for easier setup. This plugin can be installed from the Plugins tab by searching.

Updating

  • npm update -g homebridge-tplink-smarthome

Configuration

Sample Configuration

Minimal

Most setups do not require any other configuration to get up and runing.

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

All options with defaults

See config.ts for documention on these options. It is recommended to use Homebridge Config UI X to setup the configuration if you don't want to manually edit JSON files.

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

  "addCustomCharacteristics": true,
  "inUseThreshold": 0,
  "switchModels": ["HS200", "HS210"],

  "discoveryPort": 0,
  "broadcast": "255.255.255.255",
  "pollingInterval": 10,
  "deviceTypes": ["bulb", "plug"],
  "macAddresses": undefined,
  "excludeMacAddresses": undefined,
  "devices": undefined,

  "timeout": 15,
  "transport": 'tcp',
  "waitTimeUpdate": 100
}]
MAC Addresses

MAC Addresses are normalized, special characters are removed and made uppercase for comparison. So any format should work: AA:BB:CC:00:11:22 or aaBbcc001122 are valid. Glob-style pattern matching is supported: ? will match a single character and * matches zero or more. To specify all MAC addresses that start with AA you could use AA*

Eve Screenshot - Custom Characteristics

Custom Characteristics in Eve

Devices that support energy monitoring (HS110, etc) will have extra characteristics that are viewable in the Eve app (such as Watts). Turn this off by setting addCustomCharacteristics false.

Discovery and Broadcast

This plugin uses UDP broadcast to find devices on your network. This is also how the Kasa app finds devices. Try setting the broadcast configuration if you're having discovery issues. Some users have reported that rebooting their router or changing some router settings have fixed discovery issues.

Manually Specifying Devices

If you have a network setup where UDP broadcast is not working, you can manually specify the devices you'd like this plugin to use. This will send the discovery message directly to these devices in addition to the UDP broadcast. Note that your device must have a static IP to work.

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

  "devices": [
    { "host": "192.168.0.100" },
    { "host": "192.168.0.101" },
    { "host": "192.168.0.102", "port": "9999" } // port defaults to "9999" but can be overriden
  ]
}]

Accessory Names

Note the name in Homebridge/HomeKit may be out of sync from the Kasa app. This is a Homebridge/HomeKit limitation. You can rename your accessory through the Home app.

Troubleshooting

UUID Errors

Error: Cannot add a bridged Accessory with the same UUID as another bridged Accessory If you get an error about duplicate UUIDs you'll have to either remove your cached configuration files or manually edit them to remove the offending entry. By default they are stored in ~/.homebridge/accessories. In some cases you may also need to remove ~/.homebridge/persist and re-pair homebridge to your home.

You can remove them by running:

  • rm -rf ~/.homebridge/accessories
  • rm -rf ~/.homebridge/persist

Credits

Thanks to George Georgovassilis and Thomas Baust for reverse engineering the HS1XX protocol.

changelog

Changelog

All notable changes to this project will be documented in this file. See commit-and-tag-version for commit guidelines.

8.0.3 (2024-02-27)

Bug Fixes

  • Plug: Allow brightness to be set without powering on device (#335) (e0de1be), closes #333

8.0.2 (2024-01-22)

Bug Fixes

8.0.1 (2023-11-19)

Bug Fixes

  • Plug: dimmer switch on/off (#323) (deff054)

  • Plug: dimmer not turning off using brightness slider (1c2f76b)

8.0.1-1 (2023-11-19)

Bug Fixes

  • Plug: dimmer not turning off using brightness slider (1c2f76b)

8.0.1-0 (2023-11-19)

Bug Fixes

  • Plug: Fix for dimmer switch brightness change (d267e40)

8.0.0 (2023-11-17)

⚠ BREAKING CHANGES

  • Requires homebridge v1.6.0 or greater
  • Requires minimum node version v18
  • Update homebridge tests (0b2f283)

Features

  • Bulb: add bulb devices to energy monitoring polling (a587c80)
  • add emeterPollingInterval configuration (0c4995b)
  • improve debug logging for updateValue (edcbc7e)
  • add devicesUseDiscoveryPort configuration (20f25d9)
  • drop support for node < v18 (b761893)

Bug Fixes

7.1.0-next.0 (2022-02-14)

Features

  • Bulb: add bulb devices to energy monitoring polling (a587c80)
  • add emeterPollingInterval configuration (0c4995b)
  • improve debug logging for updateValue (edcbc7e)

7.0.1 (2022-02-12)

Bug Fixes

  • Bulb: remove await from get of Watts (d751d9f)

7.0.0 (2022-02-05)

Features

  • add setValue debug logging (01faa61), closes #93
  • reword log "New Device Online" to "Device First Online" (92ed0ae)
  • suppress warnings when adding custom characteristics (#242) (7a016cc), closes #201 #161 #151

7.0.0-next.0 (2022-02-03)

⚠ BREAKING CHANGES

  • requires homebridge >= 1.3.0
  • Requires node >= v12.20.0

Features

  • add support for light strips such as KL430 (7f56165), closes #113
  • throw error if non-supported homebridge version (8743552)
  • upgrade tplink-smarthome-api (eb7a670)

6.4.0 (2021-05-07)

Features

6.4.0-beta.1 (2021-03-25)

Bug Fixes

  • UnhandledPromiseRejectionWarning on log (58d9444), closes #189

6.4.0-beta.0 (2021-03-25)

Features

  • emeter polling more friendly with multi-outlet plugs (#190) (65b5865)

6.3.0 (2021-03-05)

Features

  • change characteristic getters to use cached values (#183) (8024dcc)

6.3.0-beta.0 (2021-03-01)

Features

  • change characteristic getters to use cached values (1db2c6f)

6.2.0 (2021-03-01)

6.2.0-beta.0 (2021-02-28)

Features

  • add discoveryPort configuration option (#159) (eb13885)
  • change "Apprent Power" to float (255d552)
  • logging improvements (3105f31)

Bug Fixes

  • don't update color temperature when 0 (738aeed), closes #180
  • warning for "Apparent Power" characteristic (3aa6b29)

6.1.0 (2020-10-20)

Features

  • add identify functionality to bulbs (0259e5e)

Bug Fixes

  • case typo preventing saturation updates (178df30)
  • identify not working (8b151e9)
  • return last known or default values for characteristics (59838ea)

6.0.1 (2020-10-19)

Bug Fixes

  • don't add OutletInUse for SWITCH types (59e9f42), closes #146

6.0.0 (2020-10-14)

Bug Fixes

  • only add energy characteristics if configured (52705a6), closes #144

5.2.0 (2020-10-13)

5.2.0-beta.1 (2020-10-13)

Features

  • improve homebridge-config-ui-x configuration (#142) (f7a157d)

5.2.0-beta.0 (2020-10-12)

Features

  • combine and batch requests to devices (#141) (6d6076c)

Bug Fixes

  • characteristics not being updated (5351c58)

5.1.1-beta.0 (2020-10-11)

5.1.0 (2020-05-13)

Features

Bug Fixes

5.0.0 (2020-01-09)

⚠ BREAKING CHANGES

  • Requires Node v10 or later

Features

  • stop discovery on homebridge shutdown (e138b42)
  • upgrade to tplink-smarthome-api v2 (35264b7)

Bug Fixes

  • broadcast config option not being set properly (7ff7886), closes #96

4.0.1 (2019-02-13)

Bug Fixes

4.0.0 (2019-02-12)

Bug Fixes

  • regression of addCustomCharacteristics (e087be5)

Chores

  • set minimum node version to v8.3.0 (e6abcf2)

BREAKING CHANGES

  • minimum node version supported >=v8.3.0

3.14.1 (2019-01-23)

Bug Fixes

  • update require for new index.js location (9894520)

3.14.0 (2019-01-23)

Bug Fixes

  • lightbulb: check for non-zero color_temp (8acf6e1)
  • lightbulb: incorrectly testing for Hue instead of Saturation (a823b54)

Features

  • outlet: update energy characteristics automatically (83c524f)

3.13.0 (2019-01-17)

Bug Fixes

  • correctly pass timeout to Client / Device (1481b8b)

Features

3.12.0 (2019-01-11)

Bug Fixes

  • treat HS220 as a switch by default (9e828b3)

Features

  • add excludeMacAddresses configuration (37d3ca4)
  • add support for HS300/HS107 multi-outlet devices (325b1f8)

3.11.1 (2018-12-03)

Bug Fixes

  • increase default timeout to 15 seconds (c433727)
  • support new-style energy consumption (315ee99), closes #57
  • upgrade dependencies (7453ac9)