Control Domoticz via the JSON API, configure the Homy MQTT connector

The Domoticz JSON API can be controlled very simply using MQTT messages. By connecting your Domoticz server to an online broker such as cloudMQTT, you can easily control your home automation accessories and receive status or measurement changes almost instantaneously even when you are away from home*.

(*) Need a 3G/4G internet connection or to be connected to a WiFi network obviously.

Create a free MQTT broker on cloudMQTT

cloudMQTT is a broker (server) MQTT online that offers a free offer. The free offer is limited to 5 simultaneous connections but it is more than enough for personal use. You will find other free online brokers here.

Create a free account on cloudMQTT. You will just need an email. Once logged in, click Create New Instance.

1 cloudmqtt create instance

Give a name to your instance and continue

cloudmqtt instance domoticz mqtt

Select the Cute Cate plan which is free (but limited to 5 simultaneous connections). Continue by clicking on Select Region.

 cloudmqtt plan prix

cloudMQTT uses Amazon AWS servers to function. You can choose the server on which your data will transit. Here, they will go through Ireland. Do not worry, the choice has little impact on the performance of your connection. Amazon AWS is a cloud leader…

Finish with Review

cloudmqtt localisation serveur aws

Finalize the creation of the instance on the next page by clicking Create Instancecloudmqtt create instance domoticz homy

The new instance is added to the list.

cloudmqtt instance domoticz created

Click on the name of the instance to open the connection parameters:

  • Server: the login domain name
  • User and password
  • Several ports are available

cloudmqtt mqtt instance info connexion

Configure the MQTT connection on Domoticz

Open the hardware list and add MQTT Client Gateway with Lan Interface hardware. Enter the parameters of cloudMQTT

  • Click on activate
  • address: the one indicated in the instance
  • port: here the 16338 but it can be different for you
  • user and password:
  • Topic : choose out by preference

Close by Add

cloudmtt domoticz mqtt connexion configuration

Note. The MQTT plugin for Domoticz does not support (for the moment I hope) the exchange of MQTT messages via a secure and encrypted connection. You must therefore connect to the standard port. The connection via the SSL port will lead to a connection failure.

Check that Domoticz is correctly connected to cloudMQTT

To find out whether Domoticz has connected to cloudMQTT correctly, just open the log. If this is not the case, change the port

domoticz check cloudmqtt mqtt connexion ok

Test the connection from cloudMQTT Now that everything is close, go back to cloudMQTT and open the Websocket UI. With this tool, you can view in real time all MQTT messages exchanged on the cloudMQTT broker and send messages on a particular topic. It’s great to do tests and debugging 🙂

test websocket mqtt domoticz cloudmqtt

For example, try sending a message on the domoticz/in topic to turn off an RGB bulb (here, the IDX 24)

Configure the MQTT Connector for Homy

Open the Settings

homy settings

Open the Connector List.

homy settings

Click the Plus.

homy connector list

Choose MQTT from the connector list.

homy add new connector mqtt broker

Configure the MQTT Connector with the connection parameters of a cloudMQTT instance

Complete the following parameters:

  • Name the connector. Optional
  • Check Active to enable the connector. By unchecking this option, you can suspend communication with the external temporary
  • IP broker or domain name. Specify the cloudMQTTPort server (server) name.
  • Enter the Websockets Port (TLS only) port of the cloudMQTT instance. Here 36338. The port is randomly assigned when the instance is created.
  • Protocol: choose WSS (secure) for cloudMQT
  • Finally, enter the user and password of your instance
  • Test the connection. Click on “Test Connection”. If Homy could connect and authenticate to the cloudMQTT instance, the cross will be green. An exclamation point will be displayed if this is not the case**

** Warning, the connection test is not 100% reliable. Repeat several times, waiting a few seconds between each test if the feedback is negative and your settings seem correct.

homy mqtt connector settings

Other options (optional)

You can let Homy automatically add all new Domoticz devices found on the server by checking the synchronization option

homy mqtt connector auto add new device detected

Unlike the HTTP interface, there is no function to retrieve with a single command the state (and configuration) of all available accessories. To work around this problem Homy scans the accessories up to the limit set by the auto scan field. This is a temporary solution for want of anything better. If you notice that there are missing accessories, consider adjusting the threshold of self-exploration by indicating the largest IDX of the table of the devices.

If you have several devices (smartphone, tablet …) on which you have installed Homy, you can synchronize Homy settings between your devices. All your data is synchronized via the MQTT broker. No information passes through a third party server. You keep control of 100% of your personal data!

homy mqtt connector auto discover domoticz devices

MQTT connector limitations for Domoticz

The JSON API through MQTT messages offer fewer features than the HTTP API. The technical specifications are available on the official Wiki here.

In addition to the limitations of the API, it is not possible to perform the following operations by connecting to Domoticz via an MQTT broker: The recovery of the history is not possible not possible

Other tutorials on the same theme

Click to rate this post!
[Total: 0 Average: 0]

We will be happy to hear your thoughts

      Leave a Reply

      DIY Projects