hap icon indicating copy to clipboard operation
hap copied to clipboard

Using Hap as a client to request data from a HomeKit device?

Open marcgeld opened this issue 2 years ago • 5 comments

Thanks for a great library!

I'm trying to get data from a HomeKit device. In HC there was a client example and I wondering if there is an easy way to do the same with Hap?

marcgeld avatar Feb 02 '23 21:02 marcgeld

Was wondering about that too. I tested the old example from hc-repository but didn't get it to work.

arag0re avatar Feb 02 '23 21:02 arag0re

There is currently no client implementation available. But as long as you don't have access to the encryptions keys of the HomeKit accessory, you won't be able to read any data from it.

From which HomeKit accessory do you want to read data from?

brutella avatar Feb 06 '23 10:02 brutella

I have Aqara hub with som temperature sensor I like to read data from. I managed to read data from an virtual sensor in HomeKit Accessory Simulator with your older hc library. Isn't the encryption keys generated when you connect and pair the device and it will work if I can present the numeric code on the HomeKit device when pairing with the device?

marcgeld avatar Feb 06 '23 14:02 marcgeld

Yes, the encryption keys are exchanged during pairing. But once you pair with the Aqara hub, you won't be able to add the hub to HomeKit on iOS anymore because accessories can only be paired once. You would then have to reset the accessory then.

brutella avatar Feb 06 '23 19:02 brutella

Hi,

I was asking the same question in #14

So made my implementation.

https://github.com/hkontrol/hkontroller

Take a look at examples folder.

The only problem I faced was to use standard http client with encrypted connection, so I did implement two things:

  1. Background goroutine that is reading data and transforming EVENT messages on fly.
  2. RoundTripper interface implementation to be able to use encrypted connection for http requests.

Some things sill is implemented poor and have to be rethinked in future.

shabunin avatar Feb 24 '23 17:02 shabunin