hammerspoon icon indicating copy to clipboard operation
hammerspoon copied to clipboard

[Feature] HomeKit API

Open peetzweg opened this issue 4 years ago • 7 comments
trafficstars

Hammerspoon does not have any support for HomeKit yet. It would be super cool to change brightness of lamps with a shortcut on my keyboard. There is the Home App preinstalled on Mac OS, however as far as I know there is no way to interact with it yet via a CLI.

This ticket is not proposing a solution, it should be treated as a starting point to discuss a potential solution how to add this API to Hammerspoon.

peetzweg avatar Sep 19 '21 16:09 peetzweg

The easiest way is to just “type to Siri”, so your Mac just tells Siri what to do.

However it looks like this App has deep HomeKit support:

https://apps.apple.com/au/app/homecontrol-menu-for-homekit/id1547121417?mt=12

…so I guess there must be some deeper HomeKit API’s now days. My primary machine is still on Mojave, so I haven’t really looked into HomeKit API’s for Big Sur yet.

latenitefilms avatar Sep 19 '21 20:09 latenitefilms

Didn't know about the type to Siri feature. Just looked it up and I see it potentially working with hammerspoon. Could be a great way to cheat feature into hammerspoon haha. Maybe a direkt Siri intergration via API would be nice for hs.

However, it's quite ugly IMHO to simulate a keypress and then enter a message in the pop via code. Furthermore, it's disabling the normal voice recognition feature for me.

Extending hs with the HomeKit API would be great. Myself never looked into the code of hammerspoon. As I'am not a Lua nor Objective C developer, it could be quite a challenge but an interesting one. 🤔

peetzweg avatar Sep 21 '21 16:09 peetzweg

https://developer.apple.com/documentation/homekit is where your journey begins @Pczek

shaleh avatar Sep 22 '21 16:09 shaleh

So the bad news is that the HomeKit API is only available on macOS via the Catalyst system, so Hammerspoon itself cannot access the API.

I would also be interested in having HomeKit support in HS, but likely our only route here would be to write a separate headless Catalyst app that Hammerspoon spawns and interacts with via some kind of IPC, and that's not something I've investigated yet.

cmsj avatar Sep 22 '21 16:09 cmsj

Hm sounds doable though, but also like alot of work and an external managed dependency having this additional app.

As I'm only having Philips Hue devices in my home, I came across the thought if there might be a Philips Hue app on mac os I could interact with. Then I came across this neat CLI admin tool for it. Works great so far, haven't set it up with HS yet, but should be a piece of cake as it's just a CLI command.

https://github.com/bahamas10/hueadm

However, I still think interacting with HomeKit directly would still be worthwhile and needed if one is not in the Philips hue ecosystem.

peetzweg avatar Sep 24 '21 08:09 peetzweg

Unrelated, but this might also be of interest:

https://github.com/asmagill/hammerspoon_asm/tree/master/hue

latenitefilms avatar Sep 24 '21 09:09 latenitefilms

Here's another commercial app does controls HomeKit:

https://apps.apple.com/app/apple-store/id1533590432

latenitefilms avatar Jan 19 '22 22:01 latenitefilms