Rtl_433 with MQTT receiving value 0 or unknown

Hello my first post here.

Im ruining RasPi with rtl_433 and MQTT client on one device

On second device I’ve got HA on Debian.

First configuration was all fine. I’ve managed to add sensor to HA and display temperature.
My sensor is capable of reading temp and humidity so I’ve tried to add humidity sensor based on MQTT received from RasPi then all values went to 0 or Unknown. Don’t know the reason why? I’ve reinstalled Mosquito-MQTT and removed and added user again but still the same outcome.

This is the command i run on RasPi

"rtl_433 -C si -s 1024k -F “mqtt://192.168.0.30:1883,user=matys,pass=mypass,devices=rtl_433[/id]”

On Home Assist side: can see MQTT is coming, when i listen to a topic rtl_433173/temperature_C:

Message 0 received on rtl_433173/temperature_C at 15:49:
7.5

When trying to add sensor to the dashboard, all I get is value 0 or Unknown

That is siting in my configuration.yaml

mqtt:
sensor:
- name: “Temperature”
state_topic: “rtl_433173/temperature_C”
value_template: “{{ value_json.temperature }}”
- name: “Humidity”
state_topic: “rtl_433173/humidity”
value_template: “{{ value_json.humidity }}”

Not too sure what I’m doing wrong?
This is my first post and I can’t add screenshots unfortunately.

Edit:
Just to add, Ive checked wity MQTT Explorer and all seems to be fine, no ?

Please format your code correctly with the </> button. You might have indentation errors we can’t see.

However, your problem is that you are “double-referencing” the key you need. From the look of that Explorer view, you don’t need the value_template line at all, as the value you’re getting in the topic is what you want already.

Your current configuration is trying to extract a temperature key out of 7.5.

Here’s how I’d set them up, with less generic names, random IDs (I use this), units and appropriate device_classes (docs):

mqtt:
  sensor:
    - name: "RTL Temperature"
      state_topic: "rtl_433173/temperature_C"
      unique_id: 41ea437b-98e3-4bc8-8786-84b144c44d10
      unit_of_measurement: '°C'
      device_class: temperature

    - name: "RTL Humidity"
      state_topic: "rtl_433173/humidity"
      unique_id: 12993c57-5121-406d-95c5-63102fd37fb8
      unit_of_measurement: '%'
      device_class: humidity
1 Like

Thank you for quick response. Thats my code. You’re suggesting that I should remove completely value_template ?


# Example configuration.yaml entry
mqtt:
  sensor:
    - name: "Temperature"
      state_topic: "rtl_433173/temperature_C"
      value_template: "{{ value_json.temp1 }}"
    - name: "Humidity"
      state_topic: "rtl_433173/humidity"
      value_template: "{{ value_json.humid1 }}"


I am, yes. Your temperature code would work if the topic rtl_433173/temperature_C contains {"temp1": 7.5} but it doesn’t, it just contains the value 7.5.

Note that I’ve edited my response above to add a few more things.

Alright, thank you for proving that im still noob here :smiley:
Just for future reference for others.
Now, this is how my config looks like:

mqtt:
  sensor:
    - name: "RTL Temperature"
      state_topic: "rtl_433173/temperature_C"
      unique_id: aa8f7ef2-66a6-4e31-b6d1-21d3d699d280
      unit_of_measurement: '°C'
      device_class: temperature

    - name: "RTL Humidity"
      state_topic: "rtl_433173/humidity"
      unique_id: 696caf00-18b5-4b1f-8252-afb7608207b6
      unit_of_measurement: '%'
      device_class: humidity

And all seems to be working for now:

Thanks a lot !!! :beer:

1 Like