How i can run this?

Hi,

i try to solve a Flow with my old AMP.
At the Moment i have a Shelly Plug on my Kenwood Amp to get watt. 0-3watt are standby/off 20+ watt are online. To control my AMP i build a IR Remote with Wifi.

Now i have this Flow:


MQTT messurement get power watt of shelly plug and the switch is <= or >= 10 watt. If the AMP is online, the switch change to online. If the AMP is offline, the Switch changes again. If i click on the Switch, the Amp goes online/offline cause the HTTP Request open a Link with my IR Code.

Now i want to add an automation with my Sonos Connect. If the Playstate on Playing, i will get online my AMP. If the Playstate is paused or stopped, i will change to offline (later with timeout 20minutes).

How can i do this with status of the dashboard switch, the automation change not brainless? The Request is one Command for on and off. I have no idea, how i can do this.

Sonos Playstate:


grafik

my actual work:

[{"id":"387885f8.b5df32","type":"sonos-universal","z":"7c9b27df.0bc7d8","confignode":"6e4a48f0.04709","compatibilityMode":false,"command":"group.get.playbackstate","state":"","stateType":"str","name":"","x":410,"y":360,"wires":[["8a633045.959c78"]]},{"id":"e1ec6918.1de2a8","type":"inject","z":"7c9b27df.0bc7d8","name":"","topic":"","payload":"","payloadType":"date","repeat":"10","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":360,"wires":[["387885f8.b5df32"]]},{"id":"5df92dda.dfb934","type":"http request","z":"7c9b27df.0bc7d8","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"http://10.0.0.145/ir?code=501397830","tls":"","persist":false,"proxy":"","authType":"","x":1410,"y":500,"wires":[[]]},{"id":"b9581d1d.c6ac3","type":"mqtt in","z":"7c9b27df.0bc7d8","name":"","topic":"shellies/shellyplug-s-F8CAD4/relay/0/power","qos":"2","datatype":"auto","broker":"8aa7c4c7.b6d308","x":230,"y":520,"wires":[["90b69ada.ec6428"]]},{"id":"90b69ada.ec6428","type":"switch","z":"7c9b27df.0bc7d8","name":"(1) Größer oder (2) Kleiner als 10 Watt","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"10","vt":"str"},{"t":"lte","v":"10","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":620,"y":520,"wires":[["4cdac5db.3dc314"],["f3578705.912f18"]]},{"id":"4cdac5db.3dc314","type":"change","z":"7c9b27df.0bc7d8","name":"An","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":500,"wires":[["797828c7.561bd"]]},{"id":"f3578705.912f18","type":"change","z":"7c9b27df.0bc7d8","name":"Aus","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":540,"wires":[["797828c7.561bd"]]},{"id":"8a633045.959c78","type":"switch","z":"7c9b27df.0bc7d8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"playing","vt":"str"},{"t":"eq","v":"paused","vt":"str"},{"t":"eq","v":"stopped","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":630,"y":360,"wires":[["33ed5ceb.d79cfc"],["33ed5ceb.d79cfc"],["33ed5ceb.d79cfc"]]},{"id":"33ed5ceb.d79cfc","type":"debug","z":"7c9b27df.0bc7d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1090,"y":360,"wires":[]},{"id":"797828c7.561bd","type":"ui_switch","z":"7c9b27df.0bc7d8","name":"Kenwood Status","label":"Anlage An/Aus","tooltip":"","group":"87b21765.57daa8","order":13,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":1140,"y":500,"wires":[["5df92dda.dfb934"]]},{"id":"6e4a48f0.04709","type":"sonos-config","z":"","name":"Sonos Wohnzimmer","serialnum":"94-9F-3E-21-21-22","ipaddress":"10.0.0.60"},{"id":"8aa7c4c7.b6d308","type":"mqtt-broker","z":"","name":"Mosquitto","broker":"10.0.0.171","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"87b21765.57daa8","type":"ui_group","z":"","name":"Main","tab":"7c6fa6e7.e5b808","order":1,"disp":true,"width":8,"collapse":false},{"id":"7c6fa6e7.e5b808","type":"ui_tab","z":"","name":"Home","icon":"dashboard","order":1,"disabled":false,"hidden":false}]