How to create item by content?

To get Temperature from MQTT message like

tele/sonoff-greenhouse/SENSOR = {“Time”:“2019-03-31T20:21:30”,“DHT11”:{“Temperature”:26.0,“Humidity”:21.0},“TempUnit”:“C”}

I can create item like below,

Number greenhouse_temp “Greenhouse Temp” (Lights)

But now I want to create item base on json content, for example with MQTT messages like below

tele/sonoff-DS02/SENSOR = {“ACURITE”:{“ChannelId”:5776452,“Temperature”:28.4,“Humidity”:45}}
tele/sonoff-DS02/SENSOR = {“ACURITE”:{“ChannelId”:8020548,“Temperature”:14.4,“Humidity”:50}}

I want to create two items, one for each ChannelId, messages with ChannelId 5776452 go to one item, messages with ChannelId 8020548 go to another.

Could someone help to make it work?


One way to do this would be to accept the MQTT JSON into a String Item.
Trigger a rule from Item change, analyse the JSON and update the target Items as required.

There is also a different approach here, using a REGEX in Items MQTT-1 binding. I’m not sure if you can do this with MQTT-2 (channels)

Edit - this outlines the way for MQTT-2 I think, but you’ll need the 2.5 binding