Mute Two Sonos Speakers with Node Red

I have two sonos speakers in my kitchen that cannot be used as a stereo pair. I created a Flow below that I thought would mute one upon muting the other.

When I mute the Sonos on one, nothing happens on the other. Any ideas?

[{"id":"53df64923b25f0df","type":"api-call-service","z":"d4f9ac9d.d5ff08","name":"Mute Overhead","server":"8efa78ba.f10338","version":3,"debugenabled":false,"service_domain":"media_player","service":"volume_set","entityId":"media_player.kitchen_overhead","data":"{ \"volume_level\" : 0.0 }","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":440,"y":700,"wires":[[]]},{"id":"5e843241937da4d7","type":"switch","z":"d4f9ac9d.d5ff08","name":"","property":"data.new_state.attributes.is_volume_muted","propertyType":"msg","rules":[{"t":"eq","v":"true","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":270,"y":720,"wires":[["53df64923b25f0df"]]},{"id":"7950937dc2bd11f2","type":"server-state-changed","z":"d4f9ac9d.d5ff08","name":"Kitchen Mute","server":"8efa78ba.f10338","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"media_player.kitchen_tv_speaker","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":100,"y":720,"wires":[["5e843241937da4d7"]]},{"id":"8efa78ba.f10338","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

Current state equals previous state is checked. This particular value is an attribute. If that is the only thing that changes it won’t output if that is checked.

1 Like

@JDogg016 could you explain what you did to make this work? I tried and imported your node red code and changed the entities to my own and my own server name, however it does not work (I did uncheck ‘Current state equals previous state’).
What exactly does the switch do with ‘data.new_state.attributes.is_volume_muted’?
I don’t exactly know what importing does and does not set up, but it feels as if I should put more info in the events state node as well (see image).

Thank you for your help

So sensors can have several values. The primary state and then secondary values called attributes. The event state focuses on the primary state. In this case the it’s the secondary info we need.

To get the secondary you need to leave the primary state blank. The switch is a filter that looks for the secondary value, this will allow you to use the secondary information as a trigger.

Thank you for your help! This clarifies the concept for me.
The use of a switch and using a debug to check the messages is all new to me, so I’m learning a lot.

I found out that adjusting the switch node to the value rule ‘is true’ instead of ‘== true’ is what did the trick for me.