# Connect an ESPHome device

> Connect gate controllers and boards built with ESPHome to TheBuilding.Cloud by adding an mqtt block to their YAML, then approve them in the Device Hub.

Source: https://thebuilding.cloud/help/connect-devices/device-hub-esphome
Last updated: 2026-11-15

Gate controllers and boards built with ESPHome connect to TheBuilding.Cloud through MQTT. Once set up, the device announces its relays and sensors by itself.

## What you need

- The device's ESPHome configuration (YAML) and a way to install an update to it (the ESPHome dashboard).
- An ESP32 board. The secure connection needs the server certificate, which we send you on request.
- The organisation account. Only the organisation can make site logins and approve devices.
- **Device Hub** in your menu. If it isn't there, email help@thebuilding.cloud to have it switched on.

## Get your login in TheBuilding.Cloud

1. Open **Device Hub** in the menu and click **Connect devices**.
2. Under **1 · Which site?**, click the site's login. No login yet? Click **+ New site login**, choose the **Site**, type a **Name for this login** and click **Create login**.
3. Copy the password straight away with **Copy password**. It is shown only once.
4. Under **2 · What do you have?**, click the **ESPHome** tile. Its steps already have your **Server address**, **Port (secure)** and **User name** filled in: copy each one from the tile's steps with **Copy**.

Keep this page open: you copy from it in the next step.

## Steps on the device: ESPHome configuration

1. In the device's YAML, add the **mqtt:** block from the **Connect devices** page with **Copy**. Put it in place of the **api:** block, or next to it.
2. Change **&lt;device name&gt;** to a short name for this device.
3. Put your login's password and the server certificate in your ESPHome secrets as **tbc_mqtt_password** and **tbc_ca_certificate**. Email help@thebuilding.cloud for the certificate file.
4. Install the update on the device.

### Devices that keep MQTT discovery switched off

Some ESPHome configurations have **discovery: false** in their **mqtt:** block. TheBuilding.Cloud reads those too, in ESPHome's own topics:

1. Keep **discovery: false**.
2. Set **topic_prefix** to your user name, then **/esphome/**, then the device name, for example **&lt;your user name&gt;/esphome/front-gate**. Copy the user name from the **ESPHome** tile.
3. Install the update on the device.

Switches, sensors, lights, covers (gates and blinds), locks and fans then show the same way as with discovery.

## Approve it in TheBuilding.Cloud

1. Go back to **Connect devices**. Under **3 · Devices found**, new devices show **Approve** within a minute of connecting.
2. Click the device. Under **New device: approve it to use it**, check the **Name**, choose the **Building** and click **Approve**.
3. Something you don't need? Click **Ignore**. It stays hidden and its changes aren't kept.

Until a device is approved, TheBuilding.Cloud only reads it: it can't open or switch anything.

## Check it works

- Under **1 · Which site?** the login shows **Sending now** while messages arrive.
- Open the device: **What it does** shows each part and its state, and **Recent activity** lists what changed.
- Approved devices are listed on the building's **Device Hub** tab, with one quick button where the device can be switched.

## Not working?

- **Nothing received yet**: check the server address, the secure port shown there (**8883**) with TLS (SSL) switched on, the user name and the password. All four must match the **Connect devices** page exactly.
- **Lost the password**: click **New password** on the login. Every device that used the old one stops until you give it the new one.
- **Turned off**: click **Turn this login on**.
- **The device doesn't connect**: check the certificate is in your secrets and the board is an ESP32.
- **Discovery is off and nothing shows**: check the **topic_prefix** has **/esphome/** after your user name.
- No **Device Hub** in your menu? It has to be switched on for your organisation. Email help@thebuilding.cloud.

Still stuck? Email help@thebuilding.cloud.
