plasticrake / homebridge-tplink-smarthome

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

Multi-Plug Devices as Power Strip Accessory in HomeKit #341

Open ZeliardM opened 3 months ago

ZeliardM commented 3 months ago

@plasticrake, I have tried my hand at working with your API and your plugin for TPLink Smarthome for Homebridge and first and foremost, it was very well done, and I thank you for your work.

I have made several modifications here to implement sending Multi-Plug Devices to HomeKit as a Power Strip Single Grouped Accessory with the Outlets being individually controlled.

The way your API is written, it will allow for childId's to be used, but only when coming from a Plug Device, but sense the Plugs are all just services underneath a single device, I had to work with what I had.

There may be some changes that can be done on the API side of things to work with powerStrips and have them as a deviceType, but I didn't want to mess with the API.

The changes create a single homebridge and homekit accessory, they add multiple outlet services for each outlet and then allow for those outlets to be controlled individually either in the Kasa App, Homebridge, or HomeKit and the state will update across all areas.

I also looked into several of the open issues right now with the ECONNRESET issues and I found that changing over to UDP as the transport resolved those issues, not sure if that fixes the issue, but it stops the logs. I also removed the energy characteristics from default as they are listed under the HomeKit as optional and not required or used in HomeKit, they can still be enabled, but just disabled by default.

If you have any questions about this, please let me know.