There is an enhancement request in for a formatBeforePublish parameter, akin to the one in the MQTT binding. That would do the trick, if implemented.
formatBeforePublish