“Native” HomeKit integration

Hi all of you!

I used to run homebridge as central platform for my installation. I hate the guts out of it as I am a python guy. I see no reason why JavaScript (nodejs) is any good for home automation at all.

Besides that the HomeKit integration in homebridge turns out to be the wrong way around. HomeKit can run with self defined accessories and every time you need an update, you have to hack into the sources to get your own devices back in.

After installing homeassistant it turned out HomeKit support for home assistant runs over homebridge as the default way of integrating HomeKit in homeassistant is installing nodejs and homebridge. My bad for not seeing that before I started.

Since there is nothing difficult in implementing HomeKit support (for me) in Python and Apple actually “supports” 3rd party/home brew HomeKit support for non commercial products (they put the protocol documents on their site), I found this https://github.com/ikalchev/HAP-python which is exactly what I wanted to implement.

Now I am looking for a way of integration hap-python into homeassistant and get native HomeKit support into homeassistant so we all can get rid of installing nodejs,homebridge and all the rotten JavaScript configfiles.

I want to integrate it into homeassistant, preferably without appdaemon (I run haDashboard on a wall mounted iPad). I have been reading the docs and I am unsure about where to hook into homeassistant. It should start when homeassistant starts (no separate daemon), everything I want to be available should be configurable in the main config, including the Siri string by adding some config parameters to every entity etc.

In essence the whole homeassistant setup should be a HomeKit bridge, connecting it just like you would with homebridge. All “enabled” sensors, platforms etc. would then automatically pop-up in the HomeKit app, or Elgato eve or anything else. Keeping all config in the homeassistant yaml.

I have played around a bit using the python REST api, and got stuff working pretty quickly but that is not the way to go. So I need to add a platform or similar, keeping in mind that hap-python module should be able to run and there is a connection to the event-bus of homeassistant. This is where I need some help getting pointed into the right direction of where to put this from a homeassistant point of view.

Next i will put it on git or something, At the end it should be installable with pip3 or be integrated in the homeassistant main distro. I guess may people would love to see this, especially to get rid of nodejs and homebridge for HomeKit integration. It complicates setup and updates.

So who can point me into the right direction to go. I am a busy guy and new to homeassistant developement. Adding a platform or a sensor is not a problem, it is more that such a bridge is NOT just a platform or a sensor as it will not add anything to homeassistant. I would run somewhere as a separate thread and Need to react to events (to update HomeKit) and set status in homeassistant based on events coming from HomeKit.

As soon as I find the right hooks, I would be able to get a beta available in a few days.

Martijn

16 Likes

I look foreward to this, When i turn off homebrige my processor use on a Raspberry 3 (hassio) is going down with +/- 10%.

WoW that would be great if HomeKit Could be integrated in HA

1 Like

Care to share your ongoing work on a GitHub repository ? I would gladly assist in testing

1 Like

Something like this would be great, Not having to run Homebridge and HAss

If you put it online (GitHub) I can also help you by contributing some code :slight_smile:

I too hate nodejs and had this idea has a backlog of my projects.

I use homebridge for this Homekit location to trigger automations in Home-assistant, using a software switch. Requires no Homekit-hardware!
Us this possible?

Looks like it is already on pypi…can we not just add REQUIREMENTS = ['HAP-python==1.1.1']?

Hi all!

It’s really nice to see HAP-python being integrated here and I will be happy to help. I am new to HA so don’t hesitate to correct me.

On the above code, I see you prefer value=x; notify() to a single set_value(x) which does both of these. Why is that, i.e. is there an issue with this?

EDIT
Okay my guess is that you don’t want the callback called. Note that when your callback is called, the new value is already set, i.e. set_value(self, value, should_notify=True) does:

  1. Validate new value
  2. self.value = value
  3. Call the callback with the new value (if there is a callback)
  4. Call self.notify() if should_notify

There is no need for your callback to set the value, which means you can reduce your code to just call homeassistant.services.call(...)

Best,
Ivan

Its great to see progress on this. I had a quick look on the library late last year, but had no time to actually do anything.

I’d be happy to help out if you need anything.

/R

It takes some time to get used to the design.

I’ll be looking forward to trying it out!

1 Like

After reading this topic, I tried a few things myself and just uploaded it to Github: HomeAssistant#12488

1 Like

I think what he did was just to help give an example of how to get going with getting a component up and running.

How can we help you take point @martijnm?

@cdce8p super excited…once we get the basic integration, I am sure other platforms can be added over time.

@martijnm - I echo @Robban - what can we do to help you? Unfortunately for you (at the moment), the HA project is managed with git, so being able to use git is essentially a prerequisite for being able to contribute to HA and iterate on code changes with other contributors. Those who are trying to help you get started with git are just trying to help you contribute your great ideas :slight_smile: .

1 Like

@jwelter - your points about git are well taken, git may certainly be baby steps for some but I have to say you should knock off the attitude. @martijnm is trying to contribute to the HA project and has great ideas and intentions, and it would be a real shame if the reason he couldn’t (or stopped wanting to) was because of something simple to fix or rude community members. So why do you have to come in flaming him? I don’t get it.

2 Likes

Ok well this thread is taking a turn I don’t think it should. @martijnm I’m glad to hear you’re still working on this. But from now on we should be keeping this discussion technical and leave the personal insults out of it, or the mods should lock this thread and the proper technical discussion should take place on the PR’s on GitHub.

I just read the whole thing… This is very promising.

Here is my 2 cents on that…

  • Just because you had few bad exeperiences with git, doesn’t make git dificult.
  • Nobody (at least professionally) will judge your whole carrear by looking at one component made on a new enviroment. In fact, that shows you were brave to dig in and figure all by your self. It’s not bad code, it’s just version 1.

About the git thing…
You are just dramatized with your bad experiences… you don’t need to read a book to learn how to use git. There are many tutorials / videos / articles on how to do it. 2 hours is enough.
I recommend using SourceTree App
It provides a nice GUI interface, perfect for starting.

Just learn it. If you need help, create some public tests, we can interact on a test repo and explain here whats going on.

And great work btw! :+1:

@martijnm Just caught up reading this thread and it kinda upsets me how this thread went downhill so fast. It’s actually not common in this community but I’ve experienced it too with some people who just seem to like tearing others down.

I can also understand the frustration. Sometimes having a bad experience with a product makes me setup a mental barrier too. Obviously you can do it, but when the desire is lost, it’s getting the motivation to do it that’s the problem, obviously you have the skills so it’s not that you are a dummy. Just ignore the negative posts, they aren’t worth your time. Anyways, keep up the good work! Don’t give up. There’s a lot of good people here who really value the work being done.

Since, we already have a PR in the works, I am closing this thread and purging some of the unwanted messages here. For those who are interested in contributing, feel free to open PRs after the Homekit PR is merged. The thread has outlived its purpose.

4 Likes