Hope you all had a good Christmas. For me it’s too much food and not enough coding.
I have a system working happily on RPI4 running OpenHAB 3 with Mosquitto MQTT Broker running and communicating on the same RPI4.
I have a number of temperature inputs which will send me a topic of
occ/location/ti
and the payload will be the number of the temperature sensor 1-8, followed by a ‘:’ followed by the temperature value, so a typical payload might be
1:11.6
Can somebody show me a rule which will allow me to ‘Switch/case’ on the first digit and extract the temperature value to forward to the relevant UI location?
You might be able to do this in your Thing Channel directly without a rule by using REGEX to filter for the sensor by looking for
1:
then chaining another REGEX transform to extract the temperature value. All of this would go in the transformationPattern of the Thing Channel. You can then create a separate Channel for each temperature sensor, adjusting your first REGEX filter to suit.
If you must go that way, string .split(":") would be useful.
But I’d direct effort at doing it in the channel(s) by transformation, as suggested by @hafniumzinc