REGEX JSON Help needed!

I need help with a REGEX/JSON Path expression in an MQTT Thing;

I receive telemetry data through MQTT from my Shelly2.5 device flashed with Tasmota. The telemetry JSON looks like this;

{"Time":"2021-03-22T18:12:31","Switch1":"OFF","Switch2":"OFF","ANALOG":{"Temperature":52.6},"ENERGY":{"TotalStartTime":"2021-03-22T17:33:59","Total":0.003,"Yesterday":0.000,"Today":0.003,"Period":0,"Power":[32,0],"ApparentPower":[32,0],"ReactivePower":[0,0],"Factor":[1.00,0.00],"Frequency":50,"Voltage":234,"Current":[0.135,0.000]},"TempUnit":"C"}

Uner ENERGY, the current Watt which devices connected use, is shown under “Power”. The value is shown as [x,y] where x and y are the watt for each relay on the device.

How should my channel look like to grab the “x” and the “y” values - meaning the watt for relay1 (in the JSON example it would be = 32 and 0 respectively) ?

			Type number : watt_x [
				stateTopic="tele/shelly25_1/SENSOR",
				transformationPattern="REGEX:(.*\"Power\".*)∩JSONPATH:$.ENERGY.Power"
			]
			Type number : watt_y [
				stateTopic="tele/shelly25_1/SENSOR",
				transformationPattern="REGEX:(.*\"Power\".*)∩JSONPATH:$.ENERGY.Power"
			]

Why use REGEX for this. This is the sort of thing that JSONPATH can do on it’s own. Or are you using the REGEX here as a filter?

Anyway, any time you see [ ] in a JSON it’s an array. So you just need to reference the values of the array in your JSONPATH.

JSONPATH:$.ENERGY.Power[0]
JSONPATH:$.ENERGY.Power[1]

Thanks a lot @rlkoshak !!
You are absolutely correct; I dont need the REGEX. I honestly believe I copied it into my Tasmota definitions from an example sometime and never thought too much about it as it worked :wink: Probably never got around to understand why.
Your JSON example was exactly what I needed. I just didnt know about the reference array values…

Here is the working example of channels:

	{
		Channels:
			Type switch : switch1 [
				stateTopic="stat/shelly25_1/POWER1",
				commandTopic="cmnd/shelly25_1/POWER1"
			]
			Type switch : switch2 [
				stateTopic="stat/shelly25_1/POWER2",
				commandTopic="cmnd/shelly25_1/POWER2"
			]
			Type switch : online [
				stateTopic="tele/shelly25_1/LWT",
				on="Online",
				off="Offline"  
			]
			Type number : temperature [
				stateTopic="tele/shelly25_1/SENSOR",
				transformationPattern="JSONPATH:$.ANALOG.Temperature"
			]
			Type number : voltage [
				stateTopic="tele/shelly25_1/SENSOR",
				transformationPattern="JSONPATH:$.ENERGY.Voltage"
			]
			Type number : watt1 [
				stateTopic="tele/shelly25_1/SENSOR",
				transformationPattern="JSONPATH:$.ENERGY.Power[0]"
			]
			Type number : watt2 [
				stateTopic="tele/shelly25_1/SENSOR",
				transformationPattern="JSONPATH:$.ENERGY.Power[1]"
			]
	}

You can have a channel but you can also use it to show online status of thing

Example

    Thing topic Kettle "Kettle in Kitchen" @ "Kitchen" [ availabilityTopic ="tele/kettle/LWT", payloadAvailable ="Online", payloadNotAvailable ="Offline"] {
    Channels:
        Type switch : PowerSwitch  [ stateTopic ="stat/kettle/POWER", commandTopic ="cmnd/kettle/POWER", on="ON", off="OFF"]
        Type string : WarmMode [ commandTopic ="cmnd/kettle/TuyaSend4"]
        Type number : temperature "Temperature [%.0f °C]" [ stateTopic ="tele/kettle/TUYARECEIVED", transformationPattern ="REGEX:(.*DpId\":5.*)∩JSONPATH:$.TuyaReceived.DpIdData∩JS:HEXtoDEC.js"  ]
      }