Hammerspoon / hammerspoon

Staggeringly powerful macOS desktop automation with Lua
http://www.hammerspoon.org
MIT License
11.7k stars 579 forks source link

[Feature] HomeKit API #2950

Open peetzweg opened 2 years ago

peetzweg commented 2 years ago

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.

latenitefilms commented 2 years ago

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.

peetzweg commented 2 years ago

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. 🤔

shaleh commented 2 years ago

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

cmsj commented 2 years ago

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.

peetzweg commented 2 years ago

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.

latenitefilms commented 2 years ago

Unrelated, but this might also be of interest:

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

latenitefilms commented 2 years ago

Here's another commercial app does controls HomeKit:

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