How to split incoming MQTT data to sensor

Hello all,
Hope you can help with this one. I’m trying to move from Domoticz to HA and problem with data of one of the ESP sensors which is sending 2 domoticz in topics to MQTT.
First one is :{
“idx”: 61,
“nvalue”: 0,
“svalue”: “952.00”
} where I read the svalue in a sensor based on idx==65 - that one is ok
but second topic is the one with the problem. This is going to MQTT:
{
“idx”: 65,
“nvalue”: 0,
“svalue”: “16.00;56.60;0”
}
This Svalue is temperature and humidity.
I tried several possibilities but fail to retrieve the value.
This is what I have now:

  • sensor:
    name: “Temperature - zolder”
    state_topic: “domoticz/in”
    suggested_display_precision: 1
    unit_of_measurement: “°C”
    value_template: |-
    {% if value_json.idx == 65 %}
    {{ (value_json.parameters[0].svalue) }}
    {% else %}
    {{ value_json.idx }}
    {% endif %}

Ideally there should be 2 sensors- 1 for temp and 1 for humidity but for starters 1 sensor just with the value would be fine. Very interested to learn your suggestions.
Regards,
Giel

Plz format your code:

And for you question: You can just create 2 sensors each subscribed to the same MQTT message and using the if value_json.idx == 61 for the first one and then if value_json.idx == 65 for the second sensor. No need for the else statement, that way you can specify what the value is. Temp vs Humidity

Hello Charles Evers,
Thank you for the quick reply. I put the else part in just to see what id was being used as I did not get the proper value. But I will try a few more options.
Regards, Giel

Your svalue is not a json array (and not sure where parameters come from).
try

{{ value_json.svalue.split(';')[0] | float(0) }}