HomeKit + Web = Better


When I started working on hkknx (a HomeKit bridge for KNX), my goal was to make it easier for people to control and manage their KNX devices. KNX is a home automation system where devices are mostly connected through cables (twisted pair). It’s popular in Europe and is supported by many manufacturers, like Gira, Busch-Jaeger, and MDT.

KNX has been around for over 20 years, making it a mature and stable technology. While it offers physical switches to control devices, it lacks a modern virtual user interface. This is where HomeKit shines. HomeKit, along with the Apple Home app, provides an excellent interface for controlling smart home accessories. Plus, it’s available on iPhone, iPad, and Apple Watch (though support on macOS is limited).

In my opinion, KNX works well as the back-end for a smart home, while HomeKit serves as the user-friendly front-end.

The Good And The Bad

I launched hkknx in 2020 to bridge KNX with HomeKit. The software provided a simple web interface to set up accessories and manage the KNX connection. Once set up, you could add these accessories to HomeKit and control them via the Home app. I use this software every day for my own KNX setup, and I love its simplicity and reliability.

However, as more people started using hkknx, it became clear that HomeKit alone wasn’t enough. While HomeKit is great for controlling devices and has useful automation features (like using your iPhone’s location), it also has some limitations:

  • HomeKit automations have some restrictions:
    • They can’t send notifications (e.g., “Send me a notification when the light turns on.”)
    • They don’t support if-else conditions.
    • Actions can’t be delayed (e.g., “Turn off the light 5 minutes after motion detection.”)
  • The Home app has its own set of limitations:
    • It can’t record history data for accessories (so no graphs).
    • It doesn’t show custom characteristics (like power consumption).
    • Its thermostat functions differ significantly from KNX.
  • HomeKit is only available on Apple devices, with no support for Android or Windows.

These limitations pointed me towards the next step: improving the web interface and turning it into a web app. This approach would allow me to add features not possible with HomeKit, and provide a consistent experience across multiple platforms.

Oh no, Javascript!

To move from a static website to a more dynamic one, you typically need more Javascript. I’m a big fan of simplicity, which is why I chose Go as the main programming language for hkknx—it was the right choice, and I still enjoy working with it.

However, Javascript has never been my favorite language.

After some research, I discovered HTMX, a Javascript library that lets you add interactivity using HTML attributes to communicate with the server through REST. It was exactly what I needed.

Once I tried it out, I was hooked. HTMX is a fantastic library and makes asynchronous communication with the server easy.

(I might write a separate post on how I use HTMX in hkknx.)

Rediscovering the Web

For most of my career as an app developer, I worked with with Objective-C and later moving to Swift. I never quite got into SwiftUI, though.

Switching to web development has been refreshing. I enjoy the freedom to choose my own IDE (VSCode), use any Javascript libraries I want (HTMX), and deploy changes instantly without any review process. The use of open standards (HTML, HTTP, CSS, Web Push) also means I can support all major platforms.

This approach gives me full control over my development process, which I really appreciate.

And as a bonus, tools like Go and HTML allows me to easily deploy software on my own server as a demo version.

Last updated 2024-09-11

© Matthias Hochgatterer – MastodonGithubRésumé