Only the first sensor got updates from MQTT json message

Hi,
For several hours i am trying to send data to home assistant via mqtt,
only first sensor (sensor.x_acceleration) is able to display data, other values are unknown.

In configuration.yaml i have:

  • platform: mqtt
    name: “X Acceleration”
    state_topic: “rasp1/acceleration1raw”
    unit_of_measurement: “Gs”
    value_template: “{{ value_json.acceleration_x }}”

  • platform: mqtt
    name: “Z Acceleration”
    state_topic: “office/acceleration1raw”
    unit_of_measurement: “Gs”
    value_template: “{{ value_json.acceleration_z }}”

  • platform: mqtt
    name: “Y Acceleration”
    state_topic: “office/acceleration1raw”
    unit_of_measurement: “Gs”
    value_template: “{{ value_json.acceleration_y }}”

I am sending following json:
{“acceleration_x”: -0.006170891225337982, “acceleration_y”: -0.971899151802063, “acceleration_z”: -0.0038564573042094707}

only sensor: sensor.x_acceleration got updates, others no.

When performing“Listen to a topic” in the MQTT integration
and listening for rasp1/acceleration1raw i got following info:

Message 0 received on rasp1/acceleration1raw at 8:40 PM:
{
“acceleration_x”: -0.006170891225337982,
“acceleration_y”: -0.971899151802063,
“acceleration_z”: -0.0038564573042094707
}
I assume MQTT is receiving the json properly.

Please help!
thank you :slight_smile:

The three sensors are not subscribed to the same topic.

  • The first one is subscribed to rasp1/acceleration1raw
  • The other two are subscribed to office/acceleration1raw

That’s why the first sensor reports a value and the other two report unknown.

1 Like

Taras, thank you! what a stupid mistake. I was looking into that many times and didn’t’ catch. Now it works!