MQTT Sensor kills HASS

I’ve tried this several times. I have MQTT working and can control a GPIO pin on an ESP8266. I want to monitor a DHT22 on another ESP8266 and have added the default sensor code to HASS as a start for building my sensor. As soon as I do this, HASS dies and will not start but oddly, nothing is written to the log so that makes debugging somewhat tricky (0 bytes). Can someone else try adding the default MQTT sensor component and report back? I’m running 0.25.2. Oddly, the MQTT binary sensor works just fine.

  platform: mqtt
  state_topic: "home/bedroom/temperature"
  name: "MQTT Sensor"
  qos: 0
  unit_of_measurement: "°C"
  value_template: '{{ value.x }}'

Do you have another sensor platform in your config? If so, you need to decide how to structure your YAML to cater for all sensor platform entries. This is true for all components with possibly multiple platforms. See:

It sounds weird that there’s no log output. Have you tried following the log live after start? Do this either via journal command:

sudo journalctl -f -u home-assistant@[your user]

if you run hass as a service or by just running hass manually and watch the console output.

1 Like

Thank you. I had not been taken any notice of that page as I built my system but as I only had one of everything, didn’t look like that was the issue. Started with a fresh config file and only added a couple of MQTT devices and when I add the last one to monitor temperature, HASS will not start and the logfile is 0 bytes. sudo journalctl -f -u home-assistant@pi also prints nothing out.

Yaml is here Remove the last MQTT item and HASS will start just fine.

Looks like the yr platform is not indented properly. It should have two spaces before platform, now it has three.

You are right but HASS still starts like that and the icon shows. Have corrected it though.

I’ve made a simple example to use a DHT22 sensor with a nodemcu board (esp8266). The data are published every 10 minutes. The code is available here.


  "temperature": "23.20",
  "humidity": "43.70"

Configuration :
configuration.yaml :

# Weather Prediction
  platform: yr

sensor 1:
  platform: mqtt
  state_topic: 'office/sensor1'
  name: 'Temperature'
  unit_of_measurement: '°C'
  value_template: '{{ value_json.temperature }}'

sensor 2:
  platform: mqtt
  state_topic: 'office/sensor1'
  name: 'Humidity'
  unit_of_measurement: '%'
  value_template: '{{ value_json.humidity }}'

Thanks. So this is what you get back with office/sensor1? I’m using ESPEasy which can send the temperature # direct as a payload. For some reason, HA wont start though when I add a temperature sensor but I’ll try again now and report.

I tried pasting your config into my yaml and again, HASS will not start and log not updating. I’m stuck.

im having the same problem , has this been resolved ?

It has for me.

please tell how ?

I moved my sensors over to its own yaml file which has a different formatting protocol and it worked a treat. I’d always planned to create separate yaml files but the DHT sensor issues forced my hand.

Part of my configuration.yaml to bring in the ‘sensors’

###  Devices  ###
binary_sensor: !include binary_sensors.yaml
group: !include groups.yaml
media_player: !include media_players.yaml
sensor: !include sensors.yaml
switch: !include switches.yaml

The sensors.yaml

# sensor 1:
- platform: yweather
  woeid: xxxxxxxx
  forecast: 0
   - weather
   - weather_current
#  - temp_min
#  - temp_max
   - wind_speed
#  - pressure
#  - visibility
   - humidity
   - temperature

# sensor 2:
- platform: mqtt
  state_topic: "/ESP02/Dallas/Temperature"
  name: "Desk Temp"
  qos: 0
  unit_of_measurement: "C"

# sensor 3:
- platform: mqtt
  state_topic: "/ESP02/Dallas/Humidity"
  name: "Desk Humidity"
  qos: 0
  unit_of_measurement: "%"

thanks what was it , !!

i was trying to keep all my sensors in individual files grouped in a directory called sensors.
it seems that it is just not MQTT sensor that have an issue to this type directory/file structure.
I also had yahoo weather in a sub file too …

Thanks for your help :slight_smile:

You’re welcome, glad it worked. Drove me crazy for weeks!