MQTT cannot discover my home made ESPeasy device

I have 2 MQTT devices. 1 commercial and 1 home made. Both send their info to my MQTT broker and I see the data with a MQTT explorer. The commercial device is recognized by HA and I can create graphs.
My objective is to combine tempreature data from both devices in a graph.
The home made device does not support discovery and I try to do it manualy via the configuration option under MQTT integration.
Under Publish a packet I add the following information
Topic: homeassistant/sensor/Sensors-12/Sensor01/Zone-1/config
payload:

{
	"name": "Water temperatuur zone 1",
	"unique_id": "Sensors-12_zone-1",
	"object_id": "Sensors-12_zone-1",
	"icon": "mdi:thermometer-lines",
	"state_topic": "Sensors-12/Sensor01/Zone-1",
	"unit_of_measurement": "°C",
	"device": {
		"name": "Sensors-12",
		"identifiers": "Sensors-12"
	}
}

My expectation is to find an entity Sensors-12_zone-1 depicting the temperature. But the data is not appearing. I have no errors in the log. The configuration data is depicted in my MQTT explorer.
Any help would be appreciated

The discovery topic needs to follow a specific format:

<discovery_prefix>/<component>/[<node_id>/]<object_id>/config

You have an extra level in yours.

Ok, thanks.
So I have to reduce the hierarchy to 2. Although quite an impact for other apps will make the effort and report back.

How so? The topic is HA specific and other apps need to work with that.

Next to HA, also an other app is using the data. SO, if I change the data structure at the source, I have to check the other app. No worries.

discovery topic is for meta data only. It contains information about a location of actual data. The actual data might be located anywhere else in this mqtt.

update: still not working…
I changed the message to Sensors-12/Zone-1 etc

Topic: homeassistant/sensor/Sensors-12/Zone-1/config
Payload
{
	"name": "Water temperature Zone 1",
	"unique_id": "Sensors-12_Zone-1",
	"object_id": "Sensors-12_Zone-1",
	"icon": "mdi:thermometer-lines",
	"state_topic": "Sensors-12/Zone-1",
	"unit_of_measurement": "°C",
	"device": {
		"name": "Sensors-12",
		"identifiers": "Sensor-12",
	}
}
I see the new config in MQTT explorer but cannot add it as entity to graph.
Any suggestions?

Sorry, I’m new in this arena. Not sure if I understand your remark.
My intention is to get the temperature reflected in message Sensors-12/Zone-1 etc
structure

You’re not changing the discovery topic. That’s

You changed

which is not the topic @warthog618 was talking about.

Change your state topic and device topic back, and only alter the discovery topic. I.e. Only change this topic: homeassistant/sensor/Sensors-12/Zone-1/config

it should be at most

homeassistant/sensor/<something>/config

Just to make sure I fully understand.

  1. I can make multiple levels in the MQTT message like Sensors-12/Sensor01/Zone-1
    and
  2. the topic should be homeassistant/sensor/Zone-1/config
    will make the changes

You can use this payload

{
	"name": "Water temperatuur zone 1",
	"unique_id": "Sensors-12_zone-1",
	"object_id": "Sensors-12_zone-1",
	"icon": "mdi:thermometer-lines",
	"state_topic": "Sensors-12/Sensor01/Zone-1",
	"unit_of_measurement": "°C",
	"device": {
		"name": "Sensors-12",
		"identifiers": "Sensors-12"
	}
}

and plop it into this topic

homeassistant/sensor/Sensors-12-Sensor01-Zone-1/config

Notice how there is only 3 slashes

Thanks to all, it’s working!
One more question. As you can see I have 12 sensors. Is there a way to publish them in one go? or should I publish 12 times?

You need to publish a separate config for each sensor.

Thanks for all the tips. I was able to configure my 12 sensors (one by one). Unfortunately, after a reboot all sensors indicate ‘unavailable’. They also don’t accept the next value. It can be resolved by by publishing again
If I understand well, I have to use the retain flag and created the following payload

{
	"name": "Water temperatuur zone 1",
	"unique_id": "Sensors-12-zone-1",
	"object_id": "Sensors-12-zone-1",
	"icon": "mdi:thermometer-lines",
	"state_topic": "Sensors-12/Sensor01/Zone-1",
	"unit_of_measurement": "°C",
    "retain": "true",
	"device": {
		"name": "Sensors-12",
		"manufacturer": "Maarten",
		"model": "Sensors-12",
		"identifiers": "Sensors-12"
	}
}

or should I create a configuration.yaml file?
Your help would be appreciated.

If you are generating the config messages manually then you may as well define them in the configuration.yaml. Though according to the documentation the device section only works via MQTT discovery - not from the config file.

Otherwise you either need to publish the config with retain, or if you have an active element publishing them then subscribe to the HA birth message and republish the config when HA goes online.

Similarly with the sensor state - they need to be retain or republished after HA has had a chance to process the config, be it from the configuration.yaml or the republish. If the state is being published regularly then that might be good enough.

I’ve used both approaches, with my current preference being the republish - otherwise everything ends up being retain which is poor MQTT form, AIUI.

Since the Christmas break I working on my Home assistant project and have to admid, regarding the documentation, some additional information might be helpful. I intend to document my learning as input for improvement once I have finished.
My sensors provide data every 60 seconds, so there is no need to use the retain option.
My issue is to create persistant sensor configurations. I’m able to create them manual (via integrations / configure option) but they are gone after a reboot. So, I try to define the sensors in configuration file.
Unfortunately, the documentation is ambiguous. Sometimes I see

# Example configuration.yaml entry
mqtt:
  sensor:
    - state_topic: "home/bedroom/temperature"

Alternatively

 sensor:
    - platform: mqtt
       name: "Water temperatuur zone 1"
       unique_id: "Sensors-12_zone-1"
       object_id: "Sensors-12_zone-1"
       icon: "mdi:thermometer-lines"
       state_topic: "Sensors-12/Sensor01/Zone-1"

My intend is to configure my 12 sensors and the device
Any example would be great.

The MQTT config format changed in 2022.12. Refer to the breaking changes MQTT in the 2022.12 release notes.

The current doc for MQTT sensor is correct - that corresponding to the first form. The alternate is the old form, which is no longer supported as of 2022.12. Have you tried the first form and it didn’t work for you?

e.g.

mqtt:
  sensor:
     - name: "Water temperatuur zone 1"
       unique_id: "Sensors-12_zone-1"
       object_id: "Sensors-12_zone-1"
       icon: "mdi:thermometer-lines"
       state_topic: "Sensors-12/Sensor01/Zone-1"

No tried the second version. Will try again.

Thanks for the tip, a game changer! This code is working. (If you are not sloppy with using capitals. So there is a difference between Mqtt and mqtt. Same for Sensor and sensor. my mistake)

mqtt:
  sensor:
   - name: "Water temperatuur zone 1"
     state_topic: "Sensors-12/Sensor01/Zone-1"
     unique_id: "Sensors-12_zone-1"
     object_id: "Sensors-12_zone-1"
     icon: "mdi:thermometer-lines"
     unit_of_measurement: "°C"
     device: {
       name: "Sensors-12",
       manufacturer: "Maarten",
       model: "Sensors-12",
       identifiers: "Sensors-12"
       }
   - name: "Water temperatuur zone 2"
......

Disadvantage is my configuration file gets big. Will look for an ‘include’ option.

To move your MQTT config to a separate file:

In your configuration.yaml:

mqtt: !include mqtt.yaml

In the mqtt.yaml:

sensor:
   - name: "Water temperatuur zone 1"
     state_topic: "Sensors-12/Sensor01/Zone-1"
     unique_id: "Sensors-12_zone-1"
    ...