MQTT How to select specific value from a single topic

I have two wireless temperature sensors sending values in a single topic. Each sensor has it’s own ID. Now I’m trying to show each sensors temperature value separately, i.e., sensor ID 189, temperature 20 °C, sensor ID 116, temperature 25°C.
What I have so far is:

mqtt:
  sensor:
    - name: "Siemens_GS"
      state_topic: "Temp"
      value_template: '{{ value_json }}'
      json_attributes_topic: "Temp"
      json_attributes_template: '{{ value_json | tojson }}'


This is the MQTT message (example):

{"time" : "2025-01-02 13:14:33", "model" : "Prologue-TH", "subtype" : 5, "id" : 189, "channel" : 1, "battery_ok" : 1, "temperature_C" : -18.600, "humidity" : 14, "button" : 0}

This gives both sensors values, but how can I select to receive only the values from one specific sensor?

Any idea / help very much appreciated.

post the contents of the topic please exactly as they are written in the topic.

mqtt:
  sensor:
    - name: "Siemens_GS 189"
      state_topic: "Temp"
      device_class: temperature 
      state_class: measurement
      unit_of_measurement: "°C"
      value_template: "{{ value_json.temperature_C if value_json.id == 189 else this.state }}"

    - name: "Siemens_GS 116"
      state_topic: "Temp"
      device_class: temperature 
      state_class: measurement
      unit_of_measurement: "°C"
      value_template: "{{ value_json.temperature_C if value_json.id == 116 else this.state }}"
1 Like

Thanks a lot!
The if statement in the value_statement was what I was not aware of.
Now it works and I can go on and integrate in ESPhome and show the data on a 2.23" e-paper display.