This is possibly the simplest way, using node-red-contrib-simple-gate. In fact switch and change nodes could be combined using some JSONata but that would be more difficult to see what is going on.
[{"id":"542edd66.f00d14","type":"gate","z":"d7ff0732.2f81d8","name":"","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":458.5,"y":336,"wires":[["cb0825d9.d63c6"]]},{"id":"c27d22ef.fd3fb","type":"inject","z":"d7ff0732.2f81d8","name":"Data messages come in here","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":175.5,"y":336,"wires":[["542edd66.f00d14"]]},{"id":"72868e46.f6c37","type":"inject","z":"d7ff0732.2f81d8","name":"On message from telegram","topic":"","payload":"/on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":157.5,"y":440,"wires":[["4cdd7e72.f22f18"]]},{"id":"e296973b.a98458","type":"inject","z":"d7ff0732.2f81d8","name":"Off message from telegram","topic":"","payload":"/off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":158.5,"y":475,"wires":[["4cdd7e72.f22f18"]]},{"id":"4cdd7e72.f22f18","type":"switch","z":"d7ff0732.2f81d8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"/on","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":376.5,"y":458,"wires":[["b35af95f.50d0d8"],["32f79208.824d7e"]]},{"id":"cb0825d9.d63c6","type":"debug","z":"d7ff0732.2f81d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":609.5,"y":336,"wires":[]},{"id":"b35af95f.50d0d8","type":"change","z":"d7ff0732.2f81d8","name":"Open","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"open","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":508.5,"y":433,"wires":[["542edd66.f00d14"]]},{"id":"32f79208.824d7e","type":"change","z":"d7ff0732.2f81d8","name":"Open","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"close","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":508,"y":478,"wires":[["542edd66.f00d14"]]}]
[edit] Oops, the lower Change node should be called Close
. It is only the name that is wrong though.