Your manually configured MQTT sensor(s) needs attention

Hey Andrew,

Thanks again for your help. I’ve just gotten around to making the changes and it all seems to have worked as expected.

Have a great evening!

1 Like

If you are wondering what I use to create UUIDs by the way - I just refresh this site: https://www.uuidgenerator.net/ and removed the hyphens (I don’t know if that’s necessary, but I do it anyway)

I am confused - I have lots of entries in my sensors.yaml file that look like:

# Hall Thermometer
  - platform: mqtt
    state_topic: 'home/OpenMQTTGateway/BTtoMQTT/A4C138AB1367'
    name: "Hall_temperature"
    unit_of_measurement: '°C'
    value_template: '{{ value_json.tempc | round(1) | is_defined }}'
    expire_after: 21600 # 6 hours

How do I change these and which file do I put them in ?

I tried creating a new mqtt.yaml with:

  sensor:
    - name: "Hall_temperature"
      state_topic: 'home/OpenMQTTGateway/BTtoMQTT/A4C138AB1367'
      unit_of_measurement: '°C'
      value_template: '{{ value_json.tempc | round(1) | is_defined }}'
      expire_after: 21600 # 6 hours

and:

mqtt: !mqtt.yaml

in configuration.yaml

but then my dashboard stopped working - seeming because “Hall_Temperature” sensor.hall_temperature was no longer valid, but I couldn’t find its new equivalent

So after some trial and error - I think I am making some progress, my full entry in the old format for my Hall Thermometer was:

# Hall Thermometer
  - platform: mqtt
    name: "Hall_temperature"
    state_topic: 'home/OpenMQTTGateway/BTtoMQTT/A4C138AB1367'
    unit_of_measurement: '°C'
    value_template: '{{ value_json.tempc | round(1) | is_defined }}'
    expire_after: 21600 # 6 hours
  - platform: mqtt
    name: "Hall_humidity"
    state_topic: 'home/OpenMQTTGateway/BTtoMQTT/A4C138AB1367'
    unit_of_measurement: '%'
    value_template: '{{ value_json.hum | is_defined }}'
    expire_after: 21600 # 6 hours
    icon: "mdi:air-humidifier"
  - platform: mqtt
    name: "Hall_battery_volts"
    state_topic: 'home/OpenMQTTGateway/BTtoMQTT/A4C138AB1367'
    unit_of_measurement: 'V'
    value_template: '{{ value_json.volt | is_defined }}'
    expire_after: 21600 # 6 hours
    icon: "mdi:battery-outline"
  - platform: mqtt
    name: "Hall_battery_percent"
    state_topic: 'home/OpenMQTTGateway/BTtoMQTT/A4C138AB1367'
    unit_of_measurement: '%'
    value_template: '{{ value_json.batt | is_defined }}'
    expire_after: 21600 # 6 hours
    icon: "mdi:battery-outline"
  - platform: mqtt
    name: "Hall_rssi"
    state_topic: 'home/OpenMQTTGateway/BTtoMQTT/A4C138AB1367'
    value_template: '{{ value_json.rssi | is_defined }}'
    expire_after: 21600 # 6 hours
    icon: "mdi:signal-variant"

Which I initially changed (in my new mqtt.yaml) to:

  sensor:
    - name: "Hall_temperature"
      state_topic: 'home/OpenMQTTGateway/BTtoMQTT/A4C138AB1367'
      unit_of_measurement: '°C'
      value_template: '{{ value_json.tempc | round(1) | is_defined }}'
      expire_after: 21600 # 6 hours
  sensor:
    - name: "Hall_humidity"
      state_topic: 'home/OpenMQTTGateway/BTtoMQTT/A4C138AB1367'
      unit_of_measurement: '%'
      value_template: '{{ value_json.hum | is_defined }}'
      expire_after: 21600 # 6 hours
      icon: "mdi:air-humidifier"
  sensor:
    - name: "Hall_battery_volts"
      state_topic: 'home/OpenMQTTGateway/BTtoMQTT/A4C138AB1367'
      unit_of_measurement: 'V'
      value_template: '{{ value_json.volt | is_defined }}'
      expire_after: 21600 # 6 hours
      icon: "mdi:battery-outline"
  sensor:
    - name: "Hall_battery_percent"
      state_topic: 'home/OpenMQTTGateway/BTtoMQTT/A4C138AB1367'
      unit_of_measurement: '%'
      value_template: '{{ value_json.batt | is_defined }}'
      expire_after: 21600 # 6 hours
      icon: "mdi:battery-outline"
  sensor:
    - name: "Hall_rssi"
      state_topic: 'home/OpenMQTTGateway/BTtoMQTT/A4C138AB1367'
      value_template: '{{ value_json.rssi | is_defined }}'
      expire_after: 21600 # 6 hours
      icon: "mdi:signal-variant"

But it seems that is wrong and breaks something as my sensors don’t work, but the Configuration Validation does not find anything wrong.

If I use:

  sensor:
# Hall Thermometer
    - name: "Hall_temperature"
      state_topic: 'home/OpenMQTTGateway/BTtoMQTT/A4C138AB1367'
      unit_of_measurement: '°C'
      value_template: '{{ value_json.tempc | round(1) | is_defined }}'
      expire_after: 21600 # 6 hours
    - name: "Hall_humidity"
      state_topic: 'home/OpenMQTTGateway/BTtoMQTT/A4C138AB1367'
      unit_of_measurement: '%'
      value_template: '{{ value_json.hum | is_defined }}'
      expire_after: 21600 # 6 hours
      icon: "mdi:air-humidifier"
    - name: "Hall_battery_volts"
      state_topic: 'home/OpenMQTTGateway/BTtoMQTT/A4C138AB1367'
      unit_of_measurement: 'V'
      value_template: '{{ value_json.volt | is_defined }}'
      expire_after: 21600 # 6 hours
      icon: "mdi:battery-outline"
    - name: "Hall_battery_percent"
      state_topic: 'home/OpenMQTTGateway/BTtoMQTT/A4C138AB1367'
      unit_of_measurement: '%'
      value_template: '{{ value_json.batt | is_defined }}'
      expire_after: 21600 # 6 hours
      icon: "mdi:battery-outline"
    - name: "Hall_rssi"
      state_topic: 'home/OpenMQTTGateway/BTtoMQTT/A4C138AB1367'
      value_template: '{{ value_json.rssi | is_defined }}'
      expire_after: 21600 # 6 hours
      icon: "mdi:signal-variant"

It all works again.

(Time for some sleep before I tackle the remaining sensors)

Hi.

And how did you added the mqtt sensors inside mqtt/sensors.yaml? Can you give me an example of a sensor?
I also had all the sensors inside a folder but now it’s messed up.

Ok so I think I have changed all the entries in my yaml files and everyting seems to be working - how do I confirm I have completed them all an not missed any ?

In the main config file

mqtt:
  binary_sensor: !include mqtt/binary_sensors.yaml
  sensor: !include mqtt/sensors.yaml
  switch: !include mqtt/switches.yaml

in mqtt/binary_sensors.yaml

  - state_topic: "tele/rfbridge/RESULT"
    name: 'Leak Detector'
    value_template: '{{value_json.RfReceived.Data}}'
    payload_on: 'DA3A89'
    payload_off: 'DA3A89off'
    device_class: moisture
    qos: 1

You should get another warning if you missed anything.

1 Like

Can anyone see anything wrong with this?

image

config.yaml
mqtt: !include_dir_merge_list mqtt

I have an mqtt folder in the config folder, and inside an mqtt.yaml file with these contents.
Yet this sensor never gets created and it worked just fine before this “new” way of doing mqtt sensors.

Yes. It’s not a list so you cant use

Use one of the merge_named options.

1 Like

Hi thanks , sorry for the late response i was on a business trip.

but when i do this

switch:
  - platform: template
    switches:
      wohnzimmer:
        friendly_name: "Wohnzimmer"
        turn_on:
          service: script.wohnzimmer_an
        turn_off:
          service: script.wohnzimmer_aus

mqtt:
  switch:
    - name: "test-lader-dummy"
      command_topic: "home/switch/653/power"
      state_topic: "home/switch/653/state"
      payload_on: "On"
      payload_off: "Off"
      qos: 1
      retain: true

The check configuration keeps spinning.

Are you sure it’s related to these two configurations ?
The test passes for me when I test these.

And when you test the

mqtt:
  switch:
    - name: "test-lader-dummy"
      command_topic: "home/switch/653/power"
      state_topic: "home/switch/653/state"
      payload_on: "On"
      payload_off: "Off"
      qos: 1
      retain: true

When I check the configuration I have “Configuration will not prevent Home Assistant from starting!”, so it’s OK for me.

Just because it can restart dose not mean it is correct. Did it generate any persistent notification errors?

Ok weird i do get an error 500 on the console , maybe something else. I will give it a go.

styles.ts:370 POST http://homeassistant.local:8123/api/config/core/check_config 500 (Internal Server Error)
I @ styles.ts:370
(anonymous) @ styles.ts:370
callApi @ styles.ts:370
o @ ha-card.ts:5
value @ developer-yaml-config.ts:15
handleEvent @ styles.ts:370
developer-yaml-config.ts:15 Uncaught (in promise) {error: ‘Response error: 500’, status_code: 500, body: ‘500 Internal Server Error\n\nServer got itself in trouble’}
value @ developer-yaml-config.ts:15
await in value (async)
handleEvent @ styles.ts:370