i8beef/node-red-contrib-castv2

Volume command does not work when cast target is a group

Closed this issue · 13 comments

I have tested this and keep getting the same results. I have 5 nodes triggered by an inject node for testing
node 1: sets type as volume and passes a volume value set to a number (0-100) directly to cast node
node 2: delay 15 seconds to ensure volume command has completed
node 3: sends TTS msg and passes value for text directly to cast node
node 4: delay 15 seconds to ensure msg has finished
node 5 closes connection with cast node.
This all works fine and as expected unless the target is a group not an individual cast device. If the target is a group the Volume command is ignored. If the target is a single device the flow works as expected.
image

[{"id":"c465ef49.5bfbe","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"2c8d8c64.48d5d4","type":"inject","z":"c465ef49.5bfbe","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":180,"wires":[["9821a151.3e424"]]},{"id":"bae0289e.c32428","type":"function","z":"c465ef49.5bfbe","name":"set TTS msg","func":"return {\n payload: {\n type: "TTS",\n text: "This is a test",\n volume: 75\n }\n};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":610,"y":220,"wires":[["4e7900ba.95986","71df81e4.396f3"]]},{"id":"8aaaa03a.03f51","type":"delay","z":"c465ef49.5bfbe","name":"","pauseType":"delay","timeout":"15","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":440,"y":260,"wires":[["bae0289e.c32428"]]},{"id":"9821a151.3e424","type":"function","z":"c465ef49.5bfbe","name":"set volume to 50","func":"return {\n payload: {\n type: "VOLUME",\n volume: 100\n }\n};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":340,"y":120,"wires":[["8aaaa03a.03f51","71df81e4.396f3"]]},{"id":"4e7900ba.95986","type":"delay","z":"c465ef49.5bfbe","name":"","pauseType":"delay","timeout":"15","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":940,"y":280,"wires":[["ce736630.88e658"]]},{"id":"ce736630.88e658","type":"function","z":"c465ef49.5bfbe","name":"Close","func":"return {\n payload: {\n type: "CLOSE"\n }\n};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1070,"y":180,"wires":[["71df81e4.396f3"]]},{"id":"71df81e4.396f3","type":"castv2-sender","z":"c465ef49.5bfbe","name":"cast ","connection":"163f819c.bdf01e","spotifyAccessToken":"","spotifyAccessTokenExpiration":"","spotifyDeviceName":"","x":690,"y":80,"wires":[[]]},{"id":"163f819c.bdf01e","type":"castv2-connection","name":"","target":"Office speaker","host":"","port":"8009"}]

I have a cast group too. Volume is working fine. My function-node sends:

return { payload: { type: "VOLUME", volume: 30 // 0 to 100 } }

@Einstein2150 thanks That is what my function nodes return as well and it is ignored if I send that then another function node with the TTS. Does this work for you with TTS messages?

node 1:
return {
payload: {
type: "VOLUME",
volume: 50
}
};

node 2: delay 15 seconds

node 3:
return {
payload: {
type: "TTS",
text: "This is a test."
}

};
node4: delay 15 seconds

node 5:
return {
payload: {
type: "CLOSE"
}
};

If the cast group is ALREADY set to the volume you are asking for, it won't actually do anything / output any status updates. It only emits if the value changes.

@i8beef I have tried to test this as well by setting the volume to 10 manually in the group as well as individually then running the flow (which should set the volume to 50) and it does nothing. I exported the flow that I was using to test here for reference. Any ideas?

I think that there is a difference between a group and a stereo group. In my case I have a stereo group. The stereo master device opens a new group port. Inputs to the group port are redirected to the default cast port of the stereo slave device.

In my case I have a stereo group. Volume control is working fine.

I think a logical group which groups different devices like a scene in home automation systems works different. I think you have to send the commands parallel to each affected device.

You doesn't need a delay for volume control. I send it parallel to a TTS command and it works nearly in real time.

Played around a bit, and Im not sure volume setting on groups works like this... I have a regular group setup across four speakers, and from the Google Home app itself, setting the master volume acts weird.

There seem to be others complaining about similar weird behavior: https://www.reddit.com/r/googlehome/comments/8lk01y/hey_google_set_volume_to_50_on_all_speakers/
https://support.google.com/googlenest/thread/604844?hl=en

You can probably fake it by manually setting volume on EACH device individually, but I think we might be looking at something weird about the Google cast implementation in general with speaker groups...

@Einstein2150 I have a group of google home cast devices that I created in the google home app. I did this using the "Create speaker group" option. Is this what you were referring to? @i8beef thank you I was originally doing that with the previous cast node in node red but wanted to clean it up when I realized that I could cast to a group and to also reduce the load on node red with having so many nodes. I will try playing with it a little more. Also I tried just sending the volume command to the group to set the volume to 50 and then opened the app, the whole group volume was set to 56 and the individual devices were set to different values. I then tried the same with setting the function to set volume to 10 and the levels remained unchanged.

update:
When I use this node it is only setting the volume of 1 of the devices in the group (I am assuming that this is the master in the group). This causes the overall group volume to change to an unexpected level as well. Looks like the only work around is to cast to the whole group individually. I was trying to avoid this because I am running many notifications in my house through the day so this would be a lot of overhead and load on node red, but it seems like this is the only way to go as of now. Any other ideas? As a side note I have noticed that this is not the behavior when casting Spotify. If I cast Spotify and then change the volume using the volume buttons on my phone for example or the slider bar it will adjust the volume of the devices individually and therefore reflect in the overall volume.

Yeah, sorry, it just looks like Google's implementation here is garbage. Go adjust the volume in the Google Home app of the speaker group and notice the same bad behavior. There's not much I can do to remedy that.

Im kind of surprised Spotify works though. Their cast implementation is not well regarded.

I do see some mentions that "volume adjustments only work if the Group is currently active", i.e., you have to start media playing AND THEN adjust volume. I haven't tried that yet though. You could try switching the order here and doing that, but yeah, other than that I think you'd have to build out a a quick manifold to send a VOLUME command to all items in the group directly to accomplish this.

Just an FYI, your concerns to "node-red" overhead are probably way overblown here, even on weak hardware like a Pi or something. While node in general isn't the most efficient language, this overhead would be like worrying about spilling a cup of water into a lake. 😄

Yea I am with you on that, as I'm testing their app crashed like 3 times (talk about timing lol). I did try changing the order because I read that somewhere too (the group needs to be active), but the result is that only one device in the group plays the message. I think I've got it worked out though. What I went with is using a complete node and selecting the nodes that are part of the flows that I want to notify the groups. Then I have the complete node hooked to a function that will issue the volume command to the devices individually via cast v2.

Im gonna close this out for now... I think your approach is about all you can really do right now besides screaming your concern into the void that is Google support avenues with the rest of the people who have been complaining about this for three years it seems. If you come up with anything else we can do, feel free to reopen.

Sounds good to me! Also so far so good no issues with the imp mentation I listed above. Thanks so much for taking a look at it!