Item with mixed output type mapping (string, int)?


is there an method how to map “0” to “off” and any non-zero number to be passed without modification or even better to be formatted? Something like:

Number fan_rpm "Fan [MAP(if "0" then "off" else "%s rpm")]"              <fan>             (gBoiler) { mqtt="<[mosquitto:ebus/all:state:REGEX((.*),.*,.*)]" }

I could imagine using exec (to run sed or similar editor) instead of REGEX in the binding, but a solution within openHAB would be better. (With transform? How?)


$ echo "0,20.2,0.1" | sed 's/^\(.*\),.*,.*$/\1 rpm/; s/^0 rpm$/off/'

$ echo "3600,20.2,0.1" | sed 's/^\(.*\),.*,.*$/\1 rpm/; s/^0 rpm$/off/'
3600 rpm