Lots of ways, but here is one using a ternary operator...
Try the below code into a function node.
let result = msg.payload.params.on? "on" : "off"
return { payload: result }
[{"id":"88c190a4645879b4","type":"inject","z":"217df193.d774ce","name":"True","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"command\":\"action.devices.commands.OnOff\",\"params\":{\"on\":true}}","payloadType":"json","x":165,"y":535,"wires":[["44d72ed86afee168"]]},{"id":"3d2d01e6919ffd4a","type":"debug","z":"217df193.d774ce","name":"debug 29","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":455,"y":550,"wires":[]},{"id":"44d72ed86afee168","type":"function","z":"217df193.d774ce","name":"function 7","func":"let result = msg.payload.params.on? \"on\" : \"off\"\nreturn { payload: result }","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":305,"y":550,"wires":[["3d2d01e6919ffd4a"]]},{"id":"c04febdc6d16de87","type":"inject","z":"217df193.d774ce","name":"False","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"command\":\"action.devices.commands.OnOff\",\"params\":{\"on\":false}}","payloadType":"json","x":165,"y":575,"wires":[["44d72ed86afee168"]]}]