Representing remote (mqtt) sensor data

Dear members,
Even the topic title is a bit of unclear. Sorry for that.
I am new to this environment. But learning.

The thing is I have a remote raspberry with a DHT22 sensor in a sort of annex of the house. With Node-Red I can publish the values with MQTT.

On the Home Assistant side again with Node Red I can subscribe to the MQTT topic of the values from the DHT sensor in the annex.
But I was thinking there would or should be a more elegant way to visualize these values. I have no clue where to start or how to proceed.
The sensor part of the configuration.yaml:
sensor:
# Weather prediction
- platform: yr
# speeltuig
- platform: random
#raspberry kamer-a serre
- platform: mqtt
name: “Temperatuur Serre”
state_topic: “klimaat/serre/rpi_dht22_serre”
unit_of_measurement: ‘°C’
#value_template: “{{ value_json.temperature }}”
value_template: “{{ value_json.payload }}”
- platform: mqtt
name: “Vochtigheid Serre”
state_topic: “klimaat/serre/rpi_dht22_serre”
unit_of_measurement: ‘%’
value_template: “{{ value_json.humidity }}”

The history shows some graphical background but no values have showed up there.

Please advise.

sensor:
# Weather prediction
- platform: yr

# speeltuig
- platform: random

#raspberry kamer-a serre
- platform: mqtt
  name: "Temperatuur Serre"
  state_topic: "klimaat/serre/rpi_dht22_serre"
  unit_of_measurement: '°C'
  #value_template: "{{ value_json.temperature }}"
  value_template: "{{ value_json.payload }}"

- platform: mqtt
  name: "Vochtigheid Serre"
  state_topic: "klimaat/serre/rpi_dht22_serre"
  unit_of_measurement: '%'
  value_template: "{{ value_json.humidity }}"

Please provide an example of the data published to klimaat/serre/rpi_dht22_serre. I believe it will be in JSON format and (possibly) look something like this:

{ 'temperature': 21, 'humidity': 43 }

The full msg output of the debug node in Node-Red on the raspi in the annex looks like this:
{ topic: "rpi_dht22_serre", payload: "19.60", humidity: "52.10" }

msg.payload only brings the temperature. And I left out the _msgid and isValid attributes.

You’re saying sensor.temperatuur_serre and sensor.vochtigheid_serre are not showing any values?

Sorry, I am confused by your response. Are you referring to the history graph I mentioned?
If so, there are no data points showing there only the grid.

Well now I’m confused as well.

If the states of the temperature and humidity MQTT Sensor are not appearing the in the history chart then they have either been excluded from recorder or they are simply not receiving any data.

Late this afternoon I switched on both raspi’s. To my astonishment the Home page of HA showed two circles with label names but without data.
The dev-template tool does show the names of the config sensor items but no data:
For loop example:
The random sensor is 13, the temperatuur serre is °C, the vochtigheid serre is % and the yr symbol is 1.
The history page still shows two grids but no data.
Please help.

Like I said in my previous post, the sensors are not receiving data (or you have to wait until the data is published to the broker).

Use an MQTT client, like MQTT Explorer, to confirm (independently of Home Assistant) that your MQTT broker is receiving data published to klimaat/serre/rpi_dht22_serre.

If the MQTT broker is getting the data, then you must check and confirm Home Assistant is properly connected to the broker.

As you suspected, the config for the sensor was not right. When I removed the value_template: “{{ value_json.*** }}” settings the temperature started flowing.
Now I get the same data for temp and humidity, probably because only the payload is processed.

Thanks.

I wrote something earlier but I deleted it because I think I know what might be causing the problem. The received data is not in valid JSON format:

{ topic: "rpi_dht22_serre", payload: "19.60", humidity: "52.10" }

It should look like this:

{ "topic": "rpi_dht22_serre", "payload": "19.60", "humidity": "52.10" }

When it is in proper JSON format, your two value_templates will work correctly.

I could not think of anything else then putting a json node between the dht22-node and the mqtt node with the option to output always a json string. This is on the remote pi in Node-Red. The json node has a limitation for msg.payload. I tried just msg but it gives an error when I do.
With the value_templates commented out - in HA - the information flows. Wrongly for the humidity, but is flows.
Now, when I activate the value_templates again, the data flow stops.

Something odd worth mentioning is that when I copy the debug info with the little knob on the right and copy it to my no frills text editor mousepad, it looks like this:
{“topic”:“klimaat/serre/rpi_dht22_serre”,“payload”:“22.70”,"_msgid":“f60fd3d3.fcbfa”,“humidity”:“41.40”,“isValid”:true,“errors”:1,“location”:“klimaat”,“sensorid”:“dht22”}

But when I select the items by hand and copy them it looks like this:
topic: “klimaat/serre/rpi_dht22_serre”
payload: “22.70”
_msgid: “f60fd3d3.fcbfa”
humidity: “41.40”
isValid: true
errors: 1
location: “klimaat”
sensorid: “dht22”