MQTT broker is hearing sensors, how do i make them into devices/entities?

Hi all, I’m brand-new to home assistant and to MQTT devices. I have got a pair of Pimoroni Enviro Indoor boards. I have set up an MQTT broker. Both of the boards can be heard by the broker. You can see an example of their output below. I don’t think auto-discovery is working or if that is a thing.
How do I go from here to having these devices show up as senses on a dashboard? I think I need to create entities and fill in their topics for each property on each board

{
    "pressure": 892.68,
    "temperature": 22.6,
    "timestamp": "2022-09-09 03:44:03",
    "color_temperature": 5990,
    "device": "bikeroom",
    "humidity": 46.02,
    "luminance": 18
}

For mqtt discovery to work the device has to publish a discovery message to the broker.

If it does not do that then you have to manually define mqtt sensors.

ok it doesn’t have the Discovery Message. So I have manually defined MQTT sensors. Does look correct to you? The RPi has been rebooted after the yaml was updated.
When I go to add a card to the dashboard I can’t find any cards or entities that match those sensors


# Loads default set of integrations. Do not remove.
default_config:

# Text to speech
tts:
  - platform: google_translate

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

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

sensor 2:
  platform: mqtt
  state_topic: 'enviro/bikeroom'
  name: 'Humidity'
  unit_of_measurement: '%'
  value_template: '{{ value_json.humidity }}'
sensor 3:
  platform: mqtt
  state_topic: 'enviro/bikeroom'
  name: 'luminance'
  unit_of_measurement: 'lux'
  value_template: '{{ value_json.humidity }}'

No that is not correct. Perform a Configuration check in Developer Tools → YAML before restarting. Very likely it will tell you that you have issues with your config. Sometimes only in the persistent notification area and logs. Look at the examples in the documentation again. You need to end up with this sort of structure. The indentation is important.

mqtt:
  sensor:
    - name: 'Temperature'
      unit_of_measurement: '°C'
      state_topic: 'enviro/bikeroom'
      value_template: '{{ value_json.temperature }}'
      device_class: temperature
      state_class: measurement # only include this if you want long term statistics
    - name: 'Humidity'
      unit_of_measurement: '%'
      state_topic: 'enviro/bikeroom'
      value_template: '{{ value_json.humidity }}'
      device_class: humidity
      state_class: measurement # only include this if you want long term statistics
    - name: 'Luminance'
      unit_of_measurement: 'lx'
      state_topic: 'enviro/bikeroom'
      value_template: '{{ value_json.luminance }}'
      device_class: illuminance
      state_class: measurement # only include this if you want long term statistics
1 Like

Thank you. I think i’m starting to under stand Home Assistant (at a very basic level)