MQTT Sensor naming

I’m trying to get a sensor manually configured via MQTT, and it’s just not doing what I’d like.

Here’s my configuration:

mqtt: !include mqtt.yaml

in mqtt.yaml, I have:

  - unique_id: family_room_temp_t
    name: "Family Room Temp"
    object_id: family_room_temp_t
    state_topic: "rtl_433/9b13b3f4-rtl433/devices/LaCrosse-TX141THBv2/0/92/temperature_C"
    device_class: "temperature"
    unit_of_measurement: "%C"
      - topic: "rtl_433/9b13b3f4-rtl433/devices/LaCrosse-TX141THBv2/0/92/battery_ok"
        payload_available: "1"
        payload_not_available: "0"

I have two problems:

  1. The sensor doesn’t have the expected name, and
  2. The sensor doesn’t appear in the MQTT device list.

Problem 1 is that the sensor shows up as

Family Room Temp

instead of the desired sensor.family_room_temp_t.

Problem 2 is that the only place the sensor shows up is in developer tools, not in the MQTT integration.

I’m reasonably sure that I’ve done something wrong in my YAML, but I can’t figure out what.

I can make things work with MQTT auto-discovery, but auto-discovery discovers every random 433 MHz device in a 3 block range, so I get a bunch of devices that I don’t own. So I’m trying to make things work manually.

I think the problem is that you are configuring a regular sensor and not an mqtt sensor.

The yaml config for the mqtt sensors has changed a few months ago. They are now under the mqtt: domain not the sensor: domain.

Look at the docs for the mqtt integration instead of the sensor integration.

I’ll have to admit, I’ve never used object_id, so not sure how it plays with name. Even though the docs say " Used instead of name for automatic generation of entity_id", it may be you have to remove the name line to get the object_id to be used. If all else fails, remove the object_id and simply change the name to “Family Room Temp T”.

Developer Tools are listing the “Entities”.
The MQTT Integration is only listing MQTT based “Devices”.
YAML configs are only for an MQTT “Entity”.

If you are able to make things work with Auto-Discovery, make sure to add the Device details with the Entity.
See here for examples.

I have all my mqtt stuff in a separate file (mqtt.yaml) and !include it from configuration.yaml. I updated my post to be clear.

Is there an example that sets the Device details in YAML? The sample sets them via a JSON topic, and when I set my (mqtt.yaml) as follows:

  - unique_id: family_room_temp_t
    name: "Family Room Temp"
    state_topic: "rtl_433/9b13b3f4-rtl433/devices/LaCrosse-TX141THBv2/0/92/temperature_C"
    device_class: "temperature"
    unit_of_measurement: "%C"
      - identifiers: ["family_room_temp"]
        name: "Family Room Temp"

I get an error:

Invalid config for [mqtt]: expected dictionary for dictionary value @ data['mqtt'][0]['sensor'][0]['device']. Got None

As far as I know to date, the “Device” can not be configured via YAML, only through auto-discovery.

I just punted and manually created MQTT discovery topics. Not the most straightforward, but at least it shows up where I’d expect.