I've solved a similar problem using my node-red-contrib-dsm node. I'd post the flow if requested.
node-red-contrib-dsm