Got it
[{"id":"48ce9130.1e2f8","type":"function","z":"923f92f6.5d9f2","name":"SetHeadersAndText","func":"const val = msg.payload.val\n\nflow.set(\"rhasspySiteId\", val.rhasspySiteId)\n\nlet newMsg = {};\nnewMsg.filename = `/usr/local/bin/iobroker/rhasspy/wav/${val.filename}`\nnewMsg.headers = {};\nnewMsg.headers['User-Agent'] = 'ioBroker';\nnewMsg.headers['Content-Type'] = 'audio/wav';\nnewMsg.url = `http://${val.host}:${val.port}/api/play-wav`\nreturn newMsg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":400,"y":320,"wires":[["55db20e5.403e1"]]},{"id":"55db20e5.403e1","type":"file in","z":"923f92f6.5d9f2","name":"GetFile","filename":"","format":"","chunk":false,"sendError":false,"encoding":"none","x":640,"y":320,"wires":[["f80f3dca.3cf5f"]]},{"id":"f80f3dca.3cf5f","type":"wav-headers","z":"923f92f6.5d9f2","name":"","action":"get","channels":1,"samplerate":22050,"bitwidth":16,"x":890,"y":320,"wires":[["92701f9.d1139e"],["b0ecf8e0.5cb4b8"]]},{"id":"b0763f2d.85a44","type":"http request","z":"923f92f6.5d9f2","name":"-> rhasspy","method":"POST","ret":"bin","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":1350,"y":320,"wires":[[]]},{"id":"92701f9.d1139e","type":"delay","z":"923f92f6.5d9f2","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1120,"y":320,"wires":[["b0763f2d.85a44"]]},{"id":"ae3e18ad.93ee98","type":"function","z":"923f92f6.5d9f2","name":"","func":"const rhasspySiteId = flow.get(\"rhasspySiteId\")\n\nlet newMsg = {};\nnewMsg.payload = { \n \"id\": msg.uuid,\n \"timeout\": msg.payload.duration+2,\n \"rhasspySiteId\": rhasspySiteId\n}\nnewMsg.topic = `0_userdata.0.Rhasspy.ScriptStates.${rhasspySiteId}.MopidyPaused2`\nreturn newMsg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1260,"y":400,"wires":[["5195dc22.52ab64"]]},{"id":"b0ecf8e0.5cb4b8","type":"uuid","z":"923f92f6.5d9f2","uuidVersion":"v4","namespaceType":"","namespace":"","namespaceCustom":"","name":"","field":"uuid","fieldType":"msg","x":1090,"y":400,"wires":[["ae3e18ad.93ee98"]]},{"id":"4d1fa247.ca4e2c","type":"inject","z":"923f92f6.5d9f2","name":"","props":[{"p":"payload.val","v":"{\"filename\":\"beep_error.wav\",\"host\":\"testpi.example.loc\",\"port\":\"12101\",\"rhasspySiteId\":\"testpi\"}","vt":"json"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":200,"y":320,"wires":[["48ce9130.1e2f8"]]},{"id":"715a700d.9b08b","type":"comment","z":"923f92f6.5d9f2","name":"","info":"play wav with 1sec delay\n\nThe delay is intended so that the music can be paused before","x":1350,"y":280,"wires":[]},{"id":"6a30d5b7.a0167c","type":"comment","z":"923f92f6.5d9f2","name":"","info":"use ioBroker to pause mopidy and play after the duration +2 seconds","x":1450,"y":440,"wires":[]},{"id":"5195dc22.52ab64","type":"debug","z":"923f92f6.5d9f2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1430,"y":400,"wires":[]}]
Required modules
- node-red-contrib-wav
- node-red-contrib-uuid
Also, my node-red runs inside an ioBroker.
The rest of the logic for pausing and the actual trigger comes from ioBroker.
But this logic will be of no interest to most people in this forum.
In case someone needs it. Just report it here
Thanks for your help