Yoctopuce and Home Assistant

Yoctopuce and Home Assistant

Even if Yoctopuce devices are more often used for professional automation than for private home automation, we already had the opportunity to present you some home automation applications: a ventilation system to fight humidity, a system to optimize watering according to the weather, etc. So we decided to study the possibility of integrating the monitoring of these systems on a standard home automation console: Home Assistant.

Home Assistant

Home Assistant is a free and open software intended to be a central control system for all connected objects in a house. It allows to integrate quite easily a lot of sensors and home automation actuators, supporting thousands of different products. A host of developers have contributed to its expansion, adding support for new products as their personal needs arise, creating an extremely flexible ecosystem.

Rather than courting hardware manufacturers to adopt Home Assistant as the sole standard, as commercial proprietary systems tend to do, Home Assistant has chosen to implement as many interconnections as possible with existing open protocols. In particular, thanks to an excellent integration of MQTT, Home Assistant allows to finely integrate all systems based on this protocol.


To make it simple, MQTT is a rather basic message exchange system using a central point of contact, the broker. But its use in home automation made the protocol evolve towards more and more descriptive structured messages, allowing a good coverage of all types of useful data. In particular, the appearance of gateways such as Zigbee2MQTT, capable of converting proprietary Zigbee messages into understandable MQTT messages, have made it an essential solution in home automation.

To make MQTT even easier to use, Home Assistant offers MQTT message senders the option of occasionally sending a special announcement message, which serves to describe the purpose and format of all messages they use. Thanks to this mechanism, called MQTT discovery, Home Assistant allows the user to see at a glance the detected connected objects, and to create appropriate user interfaces for these objects in a few clicks, without having to implement a specific extension for each hardware.

Home Assistant makes it easy to set up MQTT objects that implement the discovery protocol
Home Assistant makes it easy to set up MQTT objects that implement the discovery protocol

Other home automation systems such as openHAB have followed suit and recognize MQTT discovery messages coded according to the Home Assistant syntax.

Yoctopuce and Home Assistant

VirtualHub and Yoctopuce network interfaces (YoctoHub-Ethernet, YoctoHub-Wireless-n, etc.) have long had the ability to publish the status of all connected sensors and actuators to an MQTT broker. This is configured at the HTTP callback level, as documented in a previous article.

Configuration of the connection to an MQTT broker
Configuration of the connection to an MQTT broker

Today's news is that if you upgrade them to version 54000 or higher, they will now publish MQTT discovery messages allowing you to use them very easily with Home Assistant.

Yoctopuce devices now appear in the list of discovered MQTT objects
Yoctopuce devices now appear in the list of discovered MQTT objects

Clicking on a device provides its details and a link to add it to the dashboard
Clicking on a device provides its details and a link to add it to the dashboard

Installation and sample usage

If you did not yet install Home Assistant, you will find in the documentation several methods to choose from. We chose to install a brand new control machine, but since we intend to continue running our own automation scripts on that same machine, we opted for a standard Linux Mint image, and installed Home Assistant Container via Docker. The other essential components of the system (mosquitto, the MQTT broker, as well as zigbee2MQTT and Yoctopuce tools) were installed natively, because for these kind of simple little tools, Docker brings more trouble than benefits.

To test Home Assistant, we decided to see if it would indeed provide a good way to monitor our humidity control system that was set up almost ten years ago, and still works with the same Python script as originally. So we simply set up a callback on our VirtualHub to the MQTT broker, without changing anything else.

The result is quite nice. In a few clicks, we got the interface we wanted, without any effort:

It only took a few clicks to setup this monitoring dashboard
It only took a few clicks to setup this monitoring dashboard

The elements of the web interface reposition perfectly when accessed via WiFi from a cell phone. Clicking on any sensor even provides a graph of the measurement history:

Sensor history is readily available
Sensor history is readily available


The addition of MQTT discovery to Yoctopuce hubs will definitely simplify the use of Yoctopuce devices with Home Assistant. You can now add any kind of sensor (CO2, temperature, power, etc.) to your home automation system without any effort. We were impressed by the quality of the Home Assistant solution, which offered no difficulty to be configured and used even though we had never studied it before starting to work on this blog post.

An important detail to keep in mind: as it stands, the Yoctopuce MQTT integration only allows publishing values, but not changing the state of Yoctopuce devices. It is therefore perfect for measurement and monitoring, but not yet adequate for automation via MQTT. However, given the potential of this integration with Home Assistant, we might not stop there...

1 - fra Monday,april 17,2023 11H10

With my Yocto-VOC (last firmware and virtualhub on RPI), it's not working properly. Home Assistant receives MQTT messages every 1-2 seconds regardless of the interval set for callbacks. For now, I have implemented the sensor on Home Assistant with:
- platform: rest
name: voc
unit_of_measurement: "ppm"
scan_interval: 120

2 - mvuilleu (Yocto-Team)Monday,april 17,2023 15H35

@fra: the frequency set in the callback is not the reporting frequency, it is the reconnection delay. Once the MQTT connection is established, advertised values are published as soon as they change, and timed reports are published at the frequency individually set for each. The value offered in Home Assistant integration is the timed report, so you should set its frequency in the timed report configuration panel

3 - fra Friday,may 19,2023 19H37

I apologize for jumping to conclusions prematurely. I appreciate the clarification, and indeed, it is now functioning well.

4 - manu3b Thursday,december 28,2023 11H31

Looks promizing!
My Yocto sensor is connected directly to the Home Assistant Box.
My current basic solution is to install Yocto lib in Home Assistant OS, call it in a bash script, and declare in HA a
command_line sensor.
Now, the best would be to create an HA Add-on for the VirtualHUB:

5 - mvuilleu (Yocto-Team)Monday,january 08,2024 6H40

@manu3b That may be a good idea indeed, we will look at it

Yoctopuce, get your stuff connected.