Homekit & Siri voice control for Nymea (using Homebridge & MQTT)

Hi all,

I love the excellent work in this hackster post that adds voice control to nymea: https://www.hackster.io/wilrem910/low-code-private-voice-controlled-home-automation-0704d3

However, I didn’t want to invest in another microphone at this point, so I created a setup to use Siri to activate nymea scenes. Since this approach uses nymea scripts, it should allow you to do pretty much anything nymea can do with Siri voice commands.

In short, I used the mqttthing plugin for Homebridge to create switches that can be triggered by Siri (or the Home app), and send an MQTT message that is picked up by Nymea and translated into an operation of my choice, e.g. toggling a generic switch that triggers a scene.

I’m only giving a brief explanation here, but if you have any questions, feel free to post them in this topic.

  • Background: if you’re not familiar with Nymea’s MQTT broker, have a look here first: sensor-on-mqtt-server · documentation

  • Set up nymea MQTT broker as explained in the above background link, using the following settings for the MQTT Server Interface:

    Interface: “Localhost” → I installed Homebridge on the same RPi as my Nymea setup
    Port: 1884 (default port 1883 is in use)
    SSL enabled: no (uncheck)
    Login required: no (uncheck) → this is required because the homebridge plugin I use, generates a new client ID at each reboot and Nymea requires a fixed client ID (and since we’re only accepting localhost connections, this seems fine from a security point of view)

  • Add MQTT permissions:

    Client info: not relevant, since we disabled login requirements in the MQTT Server Interface
    Allowed publish topics: nymea/setScene/# (# serves as wildcard to allow multiple scene names)
    Allowed subscribe filters: none (so remove #)

  • Install Homebridge: in my example, I’m running Nymea on a Raspberry Pi, and installed Homebridge on the same RPi. Setup instructions can be found here: Install Homebridge on Debian or Ubuntu Linux · homebridge/homebridge Wiki · GitHub

  • Install mqttthing plugin for Homebridge (via the Homebridge UI): GitHub - arachnetech/homebridge-mqttthing: A plugin for Homebridge allowing the integration of many di – this plugin will allow you to create switches that can be toggled in Homekit (using the Home app or Siri voice commands).

  • Create MQTT switches for the Homebridge plugin: via the homebridge-mqttthing plugin settings, add switches that will allow you to trigger MQTT commands to nymea.

  • Via the Homebridge Config Editor, you can change the config to match what we need: for this example, I created 2 switches that can be turned on manually and switch off automatically after a few seconds, so the config looks like this ( is Localhost):

    "accessories": [
            "type": "switch",
            "name": "Entertainment Off",
            "url": "",
            "topics": {
                "setOn": "nymea/setScene/entertainmentOff"
            "turnOffAfterms": 3500,
            "accessory": "mqttthing"
            "type": "switch",
            "name": "Watch TV",
            "url": "",
            "topics": {
                "setOn": "nymea/setScene/watchTV"
            "turnOffAfterms": 3500,
            "accessory": "mqttthing"
  • Save your config and restart Homebridge, so the buttons will show up in Homekit.

  • Add an Internal MQTT client to Nymea via Configure Things, as explained in the background link (you may need to install nymea-plugin-mqttclient first), and have it listen to the following topic:

    Subscription topic filter: nymea/setScene/#

  • Using magic, you can now add the actions you want Nymea to execute when each message is received by the Internal MQTT client (make sure to select only “Payload = true”, otherwise the scene will also be triggered when Homebridge turns the button off after a few seconds (Payload = false)) → the same set of actions can also be converted to a scene, so you can also trigger it via Nymea-app:

You can now activate the Nymea scenes you created via the Home app and via Siri: “Hey Siri, watch tv” and “Hey Siri, entertainment off” will trigger the Watch TV scene or the Entertainment Off scene in Nymea respectively. Siri will respond with “OK, the Watch TV is on” or “OK, the Entertainment Off is on”, which sounds a bit weird, but hey… it works :slight_smile:

Edit: going one step further, I changed the name of the switches in Homekit to e.g. “Watch TV button” and created scenes (called f.i. “Watch TV”) that switch on the corresponding button. Siri now replies with “OK” or “Done” which makes more sense :slight_smile:

You can also create switches that can be used to turn on/off individual things, … so knock yourselves out.

I hope this can be of use to some of you. If you see ways to improve this setup, please let me know!



This is great work Rob and very clever use of MQTT. I will try it out soon.


1 Like