MQTT sensors not showing up as entity or in UI

Hello-

I am setting up an MQTT sensor following the excellent Bruh tutorial, but the only thing that shows up is the light component (which works great). One difference between the LED and the sensors is the platform (mqtt vs mqtt_json) The sensor appears to be functioning great when I look at the serial monitor in the Arduino IDE, and I have verified that the MQTT server is up and running too. I am running HA on an R Pi with a manual installation in a venv. I have set up this Bruh Sensor successfully many times in other HA instances. I am not getting any errors in the UI. Below is my config, happy to supply any other documentation.

-R

    homeassistant:
  # Name of the location where Home Assistant is running
  name: Home
  # Location required to calculate the time the sun rises and sets
  latitude: x
  longitude: x
  # Impacts weather/sunrise data (altitude above sea level in meters)
  elevation: 0
  # metric for Metric, imperial for Imperial
  unit_system: imperial
  # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  time_zone: x
  # Customization file
  customize: !include customize.yaml

# Show links to resources in log and frontend
introduction:

mqtt:
  broker: xxx.xxx.xx.xxx
  port: 1883
  client_id: x
 # keepalive: 60
  username: x
  password: x

light:  
  - platform: mqtt_json  
    name: "SN1 LED"  
    state_topic: "bruh/sensornode1"  
    command_topic: "bruh/sensornode1/set"  
    brightness: true  
    flash: true  
    rgb: true  
    optimistic: false  
    qos: 0

sensor:  

#SENSOR NODE 1

  - platform: mqtt  
    state_topic: "bruh/sensornode1"  
    name: "SN1 Humidity"  
    unit_of_measurement: "%"  
    value_template: '{{ value_json.humidity | round(1) }}'  

  - platform: mqtt  
    state_topic: "bruh/sensornode1"  
    name: "SN1 LDR"
    ##This sensor is not calibrated to actual LUX. Rather, this a map of the input voltage ranging from 0 - 1023.
    unit_of_measurement: "LUX"  
    value_template: '{{ value_json.ldr }}'  

  - platform: mqtt  
    state_topic: "bruh/sensornode1"  
    name: "SN1 PIR"  
    value_template: '{{ value_json.motion }}'  

  - platform: mqtt  
    state_topic: "bruh/sensornode1"  
    name: "SN1 Temperature"  
    unit_of_measurement: "°F"  
    value_template: '{{ value_json.temperature | round(1) }}'  


# Enables the frontend
frontend:

# Enables configuration UI
config:

http:
  # Secrets are defined in the file secrets.yaml
  # api_password: !secret http_password
  # Uncomment this if you are using SSL/TLS, running in Docker container, etc.
  # base_url: example.duckdns.org:8123

# Checks for available updates
# Note: This component will send some information about your system to
# the developers to assist with development of Home Assistant.
# For more information, please see:
# https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
updater:
  # Optional, allows Home Assistant developers to focus on popular components.
  # include_used_components: true

# Discover some devices automatically
discovery:

# Allows you to issue voice commands from the frontend in enabled browsers
conversation:

# Enables support for tracking state changes over time
history:

# View all events in a logbook
logbook:

# Enables a map showing the location of tracked devices
map:

# Track the sun
sun:

# Weather prediction
sensor:
  - platform: yr

# Text to speech
tts:
  - platform: google

group: !include groups.yaml
#group:
#  sensor_node_1_card:
#    name: Sensor Node 1
#    entities:
#      - sensor.sn1_temperature
#      - sensor.sn1_humidity
#      - sensor.sn1_ldr
#      - sensor.sn1_pir
#      - light.sn1_led


automation: !include automations.yaml
script: !include scripts.yaml

the username of the mqtt broker has to match the “bruh” bruh/sensornode1

You can re-upload the sensors by change the bruh<=== as a mqtt broker username, then you can get the result show in HA

hmm that did not seems to help. I have not done that in the past either fwiw.

I don’t think that’s true. My MQTT broker (mosquitto) username is a random string and my sensors all start with home/, e.g., home/pixel_2/charge_state.

# Weather prediction
sensor:
  - platform: yr

You can’t have two sets of sensors with the same name, either add the above to the ones at the begining of the file or name it like so …

# Weather prediction
sensor 2:
  - platform: yr
2 Likes

Ahh!!! Thank you so much. You are the man. This made it past my script check I think.

All the best,

-Revel

Thank you very much for your advice. My mqtt I have to use the same username or else it will not get the value.

Hi,

I run into a similar issue. My mqtt sensors are not showing up in HA.
see below config. Is there anything wrong with the code below?

# Sensors
sensor:
  # Weather prediction
  - platform: yr
  - platform: random

sensor 2:
  - platform: mqtt
    state_topic: "/espeasytest/DHT22/Temperature"
    name: "Temperature"
    qos: 0
    unit_of_measurement: "°C"

sensor 3:
  - platform: mqtt
    state_topic: "/espeasytest/DHT22/Humidity"
    qos: 0
    name: "Humidity"

I can see the sensor flowing in in the console:

core-ssh:/config# mosquitto_sub -h hassio.local -u ****** -P ****** -v -t "#"
/espeasytest/status/LWT Connected
/espeasytest/DHT22/Temperature 22.30
/espeasytest/DHT22/Humidity 41.50

Any suggestions?

KR, Floor