Bouke / HAP

Swift implementation of the Homekit Accessory Protocol
https://boukehaarsma.nl/HAP/
MIT License
364 stars 50 forks source link

HAP as a smart home controller (Apple TV replacement) #81

Closed voynovia closed 5 years ago

voynovia commented 5 years ago

Hi, I have a HomeKit devices but no Apple TV or iPad as a controller. Can I use HAP as a replacement?

Bouke commented 5 years ago

On your local network, homekit accessories (like a thermostat) communicate directly with a controller (e.g. an iPhone), like this:

[thermostat] <--HAP--> [iPhone]

For devices that don't support homekit directly, you can use bridge which handles the homekit protocol (HAP). For example devices that use zigbee, it would look something like this:

[light bulb] <--ZIGBEE--> [zigbee bridge] <--HAP--> [iPhone]

However when you're roaming (not on your local network), the iPhone cannot communicate to your local devices, as they are not exposed to the public internet. This is where a home hub comes into play. In short; the home hub is an Apple TV or iPad that's on your local network and signed in to the same Apple ID as your iPhone. The home hub and the iPhone will then communicate, presumably through iCloud, to control your devices. For example in the case of the thermostat:

[thermostat] <--HAP--> [home hub] <--iCloud--> [iPhone]

This package provides an implementation of HAP, where it can act on behalf of a device. So in the diagrams above, it'll be on the left side of the <--HAP--> link. As far as I know, the communication between the home hub and iCloud is proprietary and is certainly not something this package provides.

andrejcesen commented 5 years ago

So if I understand this correctly, you can have multiple HAPs, each controlling its own device?