Templating assistance needed (multiple sensors in a JSON )

Hello,

Can someone help me extract from this JSON?
This data come from MQTT client and the number of sensors is not fixed. There can be 1,2,3,…10 sensors.

{
    "type": "data",
    "message": {
        "device": "Z-PASS MQTT Client",
        "date": 1681061018,
        "signals": [
            {
                "name": "ZPASS_DI",
                "value": 0,
                "valid": 1
            },
            {
                "name": "ZPASS_DO",
                "value": 0,
                "valid": 1
            },
            {
                "name": "ZPASS_DI_3",
                "value": 0,
                "valid": 1
            },
        ]
    }
}

No option to automate this (unless you write your own intergration)
What do you want to do with the data?

I need to put “value” in each sensors.

with this syntaxe : value_json.message.signals[1].value
I managed to access the value but I would like to be able to condition it according to the name of the sensor.

Understand, but why do you need up-to-x (10?) sensors, what is the actial use of the data…graph?
Why not load them into one sensor as attributes and then work from there on?

Good idea, I’ll see what I can do with the MQTT client to enable this.

In the meantime, I’ll use a simpler JSON structure:

{
    "type": "data",
    "message": {
        "device": "Z-PASS MQTT Client",
        "date": "2023-04-09T20:49:23+0200",
        "signals": {
            "ZPASS_DI": 0,
            "ZPASS_DO": 0,
            "ZPASS_DI_3": 0,
            "ZPASS_DI_4": 0,
            "ZPASS_DO_1": 0,
        }
    }
}

Most of my input is used for graphs or lists, with a json populated sensor I can run markdown cards or apexcharts to egt to what I want. For some (!) case, I still need the individual sensors, e.g. when I want hostory and/or statistics.

I forgot… no history on attributes. So this is not a solution for my (trend) application.
I will therefore use the second JSON model