maximkulkin / esp-homekit

Apple HomeKit accessory server library for ESP-OPEN-RTOS
MIT License
1.11k stars 170 forks source link

Homekit Speaker #62

Closed AustinRobinson closed 4 years ago

AustinRobinson commented 5 years ago

Are there any examples or can someone provide an example on how to get a speaker working with this library?

renssies commented 5 years ago

Making a speaker with this library in impossible. A HomeKit speaker is a speaker with WiFi and AirPlay 2. And sadly AirPlay 2 is limited to MFi licensees who have a strict NDA.

However people could reverse engineer airplay 2 (like the did with airplay 1) but unfortunately that hasn’t happened yet

AustinRobinson commented 5 years ago

Is there any documentation on how they reverse engineered airplay 1?

AdySan commented 5 years ago

See this https://github.com/mikebrady/shairport-sync/issues/535

timoschilling commented 5 years ago

HomeKit Speaker is not the same as an AirPlay 2 Speaker.

It is right what @renssies says About the AirPlay 2 Speeker.

But it is possible to build an HomeKit Speaker with this lib.

Take a look Accessory Identifier and the related Service and add them to this projekt.

Here are the related files from an Go based lib: https://github.com/brutella/hc/blob/master/service/speaker.go https://github.com/brutella/hc/blob/master/characteristic/mute.go https://github.com/brutella/hc/blob/master/characteristic/volume.go

renssies commented 5 years ago

@timoschilling: those are the speaker services that can only used for cameras and video doorbells sadly

timoschilling commented 5 years ago

That's not true!

Here is an Devise Created by the original Apple HomeKit Accessory Simulator: image image

renssies commented 5 years ago

Yeah, that is speaker control, it is made for controlling the speaker of cameras and video doorbells. It's not supported by the official Home app but you can use it to build your own accessories to control a speaker using a different HomeKit (like the Home app by Matthias that @timoschilling is using)

However it won't let you play music to it. That is only for AirPlay 2.

timoschilling commented 5 years ago

Sure, thats how HomeKit works! But your statement Making a speaker with this library in impossible. isn't right, it's possible. HomeKit is for controlling things not for streaming Media.

timoschilling commented 5 years ago

It's like building an doorbell or an webcam with HomeKit, the controlling is the domain of HomeKit the Streaming technology not.

AustinRobinson commented 5 years ago

So to be able to stream music, Airplay 2 would need to be reverse engineered?

renssies commented 5 years ago

That is true, however, most people that mean a "HomeKit speaker" mean a speaker that appears in the Home app, which is an AirPlay 2 speaker.

So yes, you can build a HomeKit speaker with this library, meaning a speaker that you can control with a third party home app. However, you can't build a speaker that you can control using the Home app or stream music to.

And yes, in order to make a speaker that appears in the Home app and that you can stream music too from throughout iOS it will need to be an AirPlay 2 speaker. And in order to make one as a maker/hobbyist, you will have to wait for AirPlay 2 to be reverse engineered :)

AustinRobinson commented 5 years ago

Ok thanks

timoschilling commented 5 years ago

There is one other DIY way, buy an Apple AirPort Express A1392 (June 2012 or later) wich has an 3.5 mm audiojack and build it in your speaker. The A1392 has become AirPlay 2 support via an software update.

maximkulkin commented 5 years ago

Ok, personally when I hear Homekit Speaker, I also think of an AirPlay destination (so you can open your iPhone/Mac, choose it as destination and have music being streamed from your iPhone/Mac to remote speaker). That probably has almost nothing to do with HomeKit, as AirPlay should handle all manipulations (like adjusting volume). HomeKit is not needed in that setup.

Though it is kind of interesting topic. I doubt ESP8266 is capable of doing that, but ESP32 definitely can. There are two parts in it: obviously, your device need to support some audio codec (according to Wikipedia, Apple Lossless Codec) over RTP. RTP stream should also be encrypted. You can check Espressif Audio Development Framework, looks like they have some codecs already implemented. E.g. here is a live streaming example that might be very useful. The second part is to make your speaker device appear as AirPlay destination. There are a number of open source scripts/libraries for that. I checked this one and it looks like it's a simple mDNS advertisement pointing to a HTTP server that handles commands like "play" and "stop".

mentaluproar commented 5 years ago

Will this do what you want? https://github.com/mikebrady/shairport-sync

maximkulkin commented 5 years ago

@mentaluproar I am sure that there are numerous programs that implement that. The idea here was to put everything onto a $5 hardware.

Neustradamus commented 4 years ago

Any news?

mentaluproar commented 4 years ago

Any news?

Airplay2 was recently reverse engineered. I’d expect renewed interest in this soon.

maximkulkin commented 4 years ago

I would say, interest would renew if there would be off the shelf kits with ESP32 and speaker.

maximkulkin commented 4 years ago

Closing this for now, not gonna happen in near future

Neustradamus commented 4 years ago

Why close a ticket not solved?

maximkulkin commented 4 years ago

Because do not plan to do that

Neustradamus commented 4 years ago

It is not good to close this ticket if not solved... One guy can develop it...

maximkulkin commented 4 years ago
  1. Didn't happen so far. Frankly, nobody here ever worked on an issue (he did not report himself), so this list is mostly for me, and I do not want it hanging there.
  2. This issue is not related to HomeKit in general, AirPlay has nothing to do with HomeKit. Issue list is not a collection of random notes and memes from internets, it's a list of what needs to be done for this particular repo.