Homekit integration

Will Nymea get integration for HomeKit? I found nymea by accident and decided to try it,
I was delighted and I really liked it. I’m looking for a way to expose my lights and sensors to a homekit.
Is there a way or APi through which to expose my nymea accessories to Homebridge?

Hi @Kristian8606

At this point I cannot put an estimate on homekit integration. I don’t think anyone is working on it currently. That said, sure something that would fit in and we’d be thankful for any contribution. If someone wants to get that going, I can sure help with getting started from the nymea point of view. Don’t have too knowledge on the homekit side myself so far.

I can develop a plugin for homebridge, but I still don’t know how to access the devices that are exposed by nymea

The goal would be to expose all things in nymea to homekit, right?

If so you’d want a experience plugin. In there you have full access to all things in nymea. We don’t have any open source example available for that right now but it’s kinda the same as regular plugin development with the difference that you won’t need a JSON file and subclass ExperiencePlugin instead of Integrationplugin. You’ll get a pointer to the ThingManager in the constructor and have it all there then.

Let me know if you need more. I’m happy to help.

This would be a suitable .pro file:

QT -= gui
QT += network

TARGET = $$qtLibraryTarget(nymea_experiencepluginhomekit)

CONFIG += plugin link_pkgconfig c++11
PKGCONFIG += nymea

SOURCES += experiencepluginhomekit.cpp ...

HEADERS += experiencepluginhomekit.h ...

target.path = $$[QT_INSTALL_LIBS]/nymea/experiences/
INSTALLS += target

This is the class you’d need to subclass: https://github.com/nymea/nymea/blob/master/libnymea/experiences/experienceplugin.h

Override the init() and set up stuff there. Use thingManager() to get all the things.

For testing, you can start nymead with

NYMEA_EXPERIENCE_PLUGINS_PATH=/path/to/builddir/ nymead -n -d Experiences -d ThingManager

Hope this helps,

Actually I might have been too fast there… I don’t even know how the homebridge stuff is working… Would you connect to homekit/homebridge from the nymea process or connect from the homebridge process to nymea? The above would be if the nymea process connects to homebridge.

If instead you’d connect from homebridge to nymea, then I suppose you’d want to use nymeas jsonrpc api as described here: https://nymea.io/documentation/developers/clients/client-development

My test plugins works well with Deconz. It has a lightweight HTTP server through which it updates the accessories as well as Websocket.

Such a server will help to integrate nymea not only to the homebridge but also to others.

Right now we don’t have a REST API available. We had one but it was not used and outdated so we removed it.

REST is not the best suited protocol for this use case. It’s quite hweavy on the resources and people tend to poll it for changes which is very bad for the user experience. Even if you poll in 1 second intervals, this adds a delay that’s too long to reasonably well work with control events like button presses and such.

Instead I’d recommend connecting to the nymea API via a plain TCP socket or WebSocket. It’s not actually harder to use than REST calls. In what language is your test plugin written? I could probably help you getting the connection set up using nymea’s RPC API.

Anyhow, in general I do agree that having a REST based API also has some advantages and we will bring it back at some point. To solve the polling problem, we’d probably go for a long-poll queue unlike the deconz REST API.

TypeScript or JavaScript. I will be grateful if you help me.

I followed the documentation and was able to connect via TCP. I received a token but I can’t find documentation on how to take the status of the accessories as well as set their status. Is it possible to help me?

Ah nice, I was about to post an example on how to connect via tcp and nodejs.

So mainly you need the Integrations namespace. Nymea uses “ThingClasses” to describe all the device/service types it knows and “Things” for the actual configured devices/services and their status.

Get the complete list of supported ThingClasses them via Integrations.GetThingClasses:

To get the actual configured things and their status you’d use Integrations.GetThings:

Then you use Integrations.ExecuteAction to control things.

In order to receive status change updates you’d call JSONRPC.SetNotifications passing [Integrations] as the namespace you want to be notified for. After calling that, you’ll see updates coming in whenever some status changes.

Hey @Kristian8606,

I’ve pushed my example code to

You probably have figured out most of the stuff yourself by now, but there are some quirks you might run into like package splitting. Hoping my example will be useful.

I’ve added support for authentication and notification… Let me know how it goes.

Great Thank you!
Thanks for the good work, i get an update on (things)

I would ask you for an example of (Integrations.ExecuteAction) as I still fail.


sure, no problem. will add that…

Great to see you’re making good progress!

Done. Directly after connecting, the example would now turn on all lights.

Hey @Kristian8606

is there any progress on this? Perhaps something you could share with others in here?

I’d also be very interested in an update on this.