Adding mqtt sensor without configuration.yaml edits

So I have learned that I cannot add sensor without HA restart, which I do not want to do. I need to add sensor in configuration.yaml and then restart HA. No.

Instead, I have seen that mqtt Mosquitto integration picked up new sensors that I created, without even touching the yaml file and HA restart. So I have published topic to mqtt broker like bitcoin/rate with payload (exchange rate) and I expected I will see new entity in mosquitto integration. But no new entity is there.

How it comes that other sensors (like esphome ones) are added automatically to HA mosquitto, but not the topic “bitcoin/rate”?

That’s incorrect. You don’t need to restart Home Assistant in order to add a new MQTT entity. Simply execute Developer Tools > Server Controls > Reload Manually Configured MQTT Entities.

The technique to automatically create MQTT entities is known as MQTT Discovery and it involves publishing a specific kind of payload to a specific topic.

Example to create a binary_sensor.

I provided a brief tutorial here for how to do it using scripts:

Some sensor could also be using MQTT discovery where the sensors register their “existence” automatically by sending a message to a specific topic. Then they automatically become visible (and selectable in for creating graphs / panels, etc).

I should be able to use mosquitto_pub to publish a message that creates new sensor, right? What would be the format of such message?

The required format is documented in the MQTT Discovery link I posted above.

Most probably I’m too stupid for this, but I don’t see/have this single menu item? Was it removed/replaced/…? I tried already pressing all other options, but the entities came only with full restart.

That was a mistake; it was always under Configuration and never under Developer Tools. However, its menu position did move slightly since that post was written. Here’s the current location (version 2022.4.7):

Configuration > Settings > Server Controls > Reload Manually Configured MQTT Entities
1 Like

O.k. Thanks. I already looked there. But is it possible, that it is only there, if there is a single reboot after a single MQTT-entity has been created? 100% the menu item was not there, now it is.

The menu option won’t exist if there are no existing manually configured MQTT entities.