Unable to add any new MQTT sensor

Hi, I started having a strange issue with my HA MQTT sensors. I have many MQTT sensors and they are all working fine but I cant add any new MQTT sensors. I think this happened after I updated to the latest version of HA from a June 2022 version of HA but not sure.
My env:
HA : supervised on Debian
HA version : 2022.12.1
Here is my config for MQTT sensors in the file mqtt_sensor.yaml:

- state_topic: "home/espnow/solar_geyser/state"
  name: "Solar Geyser Temperature"
  unique_id: solar_geyser_temperature
  value_template: >
      {{ value_json.fval1 }}
  device_class: temperature
  unit_of_measurement: "°C"

- state_topic: "home/espnow/solar_geyser/state"
  name: "Solar Geyser Battery Volt"
  unique_id: solar_geyser_battery_volt
  # Trim the upper value of battery voltage to 4.2v
  value_template: >
    {% if(value_json.fval2)|float > 4.2 %}
      {{ 4.2 }}
    {% elif(value_json.fval2)|float < 3.5 %}
      {{ 3.5 }}
    {% else %}
      {{ value_json.fval2|float|round(2) }}
    {% endif %}
  unit_of_measurement: "V"

I use split files so the following entry is there in configuration.yaml & mqtt.yaml

mqtt: !include mqtt/mqtt.yaml

sensor: !include mqtt_sensor.yaml

Of the above solar_geyser_temperature shows up as “Disabled by MQTT integration” while the pre-existing one solar_geyser_battery_volt works fine.
I have tried putting in a new sensor with a new name and everything else, I just cant show up any new sensor. All of them are shown as Disabled by MQTT. I have seen the HA core logs and there’s no mention of these disabled sensors in the logs.
What am I doing wrong?

Hello,

the only difference i notice is my sensors always begin with “- name:” not “-state_topic:” but perhaps thats not the problem. Try like this perhaps:

mqtt:
  binary_sensor:
    - name: Bureau Motion Sensor DVR
      state_topic: "Agent/cameras/bureau/motion"
      payload_on: "true"
      payload_off: "false"
      device_class: motion
      unique_id: bureau_motion_sensor_dvr

well, at this point I have tried so many things, I can try this too. But as I said the issue is not only with this sensor. Any new sensor that I create on any topic just shows up as a Disabled MQTT sensor. I have not touched the existing ones as they might also stop working. I have over 30 MQTT sensors - they are all working fine without issues.
Remembering now, I think this issue started after I migrated to the new MQTT config as old one is deprecated in the Dec release.

yes there are some changes now with manual sensors.

I got some problem too, dont remember what to do to solve it…
the docs say:

To use your MQTT sensor in your installation, add the following to your configuration.yaml file:

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

and previous style was :

The configuration format of manual configured MQTT items has changed. The old format that places configurations under the sensor platform key should no longer be used and is deprecated.

The above example shows the new and modern way, this is the previous/old example:

sensor:
  - platform: mqtt
    state_topic: "home/bedroom/temperature"

but seems that you already do

but

sensor: !include mqtt_sensor.yaml

shouldnt be :

sensor: !include mqtt/mqtt_sensor.yaml

???

Thanks for the suggestion but my config is correct. I split all mqtt files into many like mqtt_sensor.yaml , mqtt_binary_sensor.yaml etc. and all of these are included in the file mqtt.yaml included in configuration.yaml

is that the same problem?

path problem like you in post#29

I think your problem is this

mqtt: !include mqtt/mqtt.yaml

sensor: !include mqtt_sensor.yaml

First you have mqtt:
That uses up the mqtt keyword. You are done. It is burned.

Then you have sensor:

You do not say what you have their but with the new mqtt sensor style that was introduced 6 months ago and enforced now the old platform: mqtt is gone

The overall principle now is

mqtt:
  sensor:
    sensors here
  binary_sensor:
    binary sensors here
  light:
    lights here
etc

There are many ways to do this.

Flag in configuration.yaml - messy

Create a directory with multiple files that get merged as if they were one. You can then put all sensors in one and binary sensors in another. Here we call the directory mqtt

mqtt: !include_dir_merge_named mqtt

And inside each file, which must end with .yaml, you put your items starting with the domain keyword like sensor: or binary_sensor:

sensor:
   
  - name: "nfcmqtt"
    state_topic: "alarm/nfcid"
    unique_id: "nfcmqtt"
    
  - name: "Bathroom Rising"
    state_topic: "fan/rising"
    unique_id: "Bathroom Rising"
    unit_of_measurement: '%'
  
  - name: "Bathroom Falling"
    state_topic: "fan/falling"
    unique_id: "Bathroom Falling"
    unit_of_measurement: '%'

A third way is to have this in configuration.yaml

mqtt:
  sensor: !include mqtt_sensors.yaml
  binary_sensor: !include mqtt_binary_sensors.yaml

And there are more ways here every item has its own file if that pleases you.

The overall idea is that for all mqtt defined items the mqtt keyword must be the top level and then below that the keyword for each type (sensor, light, switch etc) and below that each item.

1 Like

Hmm, you make me think, I thought I had sorted out all this when I migrated as I saw all my sensors work well. I will restructure it and report back. Thanks

@KennethLavrsen , you saved my day! You rock man! Yes that was the issue. For some reason all existing sensors were working - not sure why and that’s why I did not pay attention the fact that the config could be wrong.
Thank you buddy!

thats what i point you too in my previous post

Sorry, I did not notice your reply and straight saw an email notification for the other one. Yes, your solution also points to the same. Thank you again for spending time to help me out here.

1 Like

thanks, your Welcome, happy you solved !

Who can help me.

I want a sensor for humidity but how do i add this.
I used mqtt explorer for info of sensor
Unther remotesinfo: that is what i want to read in home assistant hum 68

You reply to a 2 year old topic that is about something totally different. Better create a new topic, more chance of getting help.