AboutBlogContact
Advanced & Guides

Controlling other boneIO Black by MQTT

Guide how to controll other boneIO Black directly by MQTT

Quick Introduction

MQTT Broker

Before we proceed to the main part of the manual, we need to mention MQTT itself. According to previous documentation, the most recommended option for the MQTT broker is to configure it directly on the boneIO Black. For the purpose of this tutorial, we assume that this is how you have configured your environment. Additionally, we assume that both controllers are in a common network and use the same broker.

Assumptions

In our example configuration, we have two boneIO Black controllers (32x10A). We named the first one boneio1, and the second one, analogously, boneio2. The name: line in the boneio section is responsible for our device's name on the network - spaces are replaced with the "_" character. If we want to give the device a custom short name in MQTT, we can use the topic_prefix: header, which is found in the mqtt.yaml file. In that case, the name is assigned based on this prefix, and this is how one boneIO controller recognizes the other.

How to control the output of the second controller using the input of the first one?

It is extremely simple. In our scenario, using input no. 1 IN_01 on boneio1 – specifically the single press button action – we want to change the state of output 1 OUT_01 on the boneio2 controller.

To achieve this, the only thing we need to do is edit the event.yaml file on the boneio1 controller.

Below is an example configuration:

- id: IN_01
  boneio_input: IN_01
  actions:
    single:
      - action: output_over_mqtt
        boneio_id: boneio2
        pin: OUT_01

What have we done? Compared to the default file, we introduced minor changes. Namely, in our - action: section, we changed the standard output parameter to output_over_mqtt. As the name suggests, it enables changing the output state via the MQTT protocol.

Next, we provide the parameters:

  • boneio_id: - here we enter the name of the controller whose output we want to control (in our case boneio2).
  • pin – here we provide the name of the specific output, i.e., OUT_01.

What do we achieve with such a configuration? By performing a single click action with the button connected to input IN_01 on boneio1, we directly control output OUT_01 on boneio2. Everything happens within the logical layer of boneIO controllers, and all communication takes place directly between them.

What does this mean in practice? We create a local ecosystem completely resistant to potential failures of superior smart home systems (e.g., Home Assistant).