MQTT sensors from domoticz, only first one works, why?

Hello to all, I’m new to ha.

I’m trying to import some mqtt values inside domoticz, and I’m using this config:

  - platform: mqtt
    name: "Autoconsumo"
    unique_id: “Autoconsumo”
    state_topic: "domoticz/in"
    unit_of_measurement: 'kWh'
    force_update: false
    value_template: "{% if value_json.idx == 5 %} {{ value_json.svalue }} {% endif %}"
    device_class: energy
    state_class: measurement


  - platform: mqtt
    name: "Sunnyboy"
    unique_id: “Sunnyboy”
    state_topic: "domoticz/in"
    unit_of_measurement: 'kWh'
    force_update: false
    value_template: "{% if value_json.idx == 95 %} {{ value_json.svalue }} {% endif %}"
    device_class: energy
    state_class: measurement

  - platform: mqtt
    name: "Consumo Total"
    unique_id: “Consumo Total”
    state_topic: "domoticz/in"
    unit_of_measurement: 'kWh'
    force_update: false
    value_template: "{% if value_json.idx == 92 %} {{ value_json.svalue }} {% endif %}"
    device_class: energy
    state_class: measurement

The trouble is that only that first sensor works properly, the other ones shows zero. Why?

What is the value of “value_json.idx”?

If it isn’t either 95 or 92 then those sensors values should be unknown. I’m surprised it’s 0.

Fixed, the trouble was the format, I had to use like this:

sensor:
  - platform: mqtt
    name: "Autoconsumo"
    unique_id: “Autoconsumo”
    state_topic: "homeassistant/autoconsumo"
    unit_of_measurement: 'Wh'
    force_update: false
    value_template: "{{ value_json }}"
    device_class: energy
    state_class: measurement
    last_reset_topic: "homeassistant/autoconsumo"
    last_reset_value_template: entity_id


  -   platform: mqtt
      name: "Sunnyboy"
      unique_id: “Sunnyboy”
      state_topic: "homeassistant/sunnyboy"
      unit_of_measurement: 'Wh'
      force_update: false
      value_template: "{{ value_json }}"
      device_class: energy
      state_class: measurement
      last_reset_topic: "homeassistant/sunnyboy"

FYI that format is the old style.

Old:

sensor:
    -  platform: mqtt
        name: sunny
New:

mqtt:
    sensor:
       -  name: sunny
           state_topic: etc etc

       -  name: nextentry