How to change volume tts.google_say nodered

you may save state with state node also

Thanks a lot! So I have the current state. If I’m right “vana_magata” is the variable for the volume. So the volume is stored in “vana_magata”.
To be honest, I’m still not clear :frowning:
Can you please post the window screenshot of the “Function” node and the “Call service node” whict sets back to the original?

service node and data part:

{    "volume_level": {{flow.vana_laud.attributes.volume_level}}}

and i’m not using function node at all.
sorry screenshots are from different flows, but you should use flow.yourname

Hi, how did you get that output?

This is my flow:

[{"id":"f0e4ec9b.c55fd","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"17f121a5.e5dcce","type":"inject","z":"f0e4ec9b.c55fd","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":970,"y":160,"wires":[["fcb04c1c.2d1d5"]]},{"id":"e555f204.9b437","type":"debug","z":"f0e4ec9b.c55fd","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1250,"y":160,"wires":[]},{"id":"fcb04c1c.2d1d5","type":"api-current-state","z":"f0e4ec9b.c55fd","name":"g mini","server":"46a5f96a.e810e8","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"media_player.family_room_speaker","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1120,"y":160,"wires":[["e555f204.9b437"]]},{"id":"46a5f96a.e810e8","type":"server","name":"Home Assistant","addon":true}]

This is the output I get:

play something on mediaplayer and look then debug

You don’t need to play anything, just media_player.turn_on, delay 1 second, read state.

I can’t seem to figure out how to set the volume back to the original.
i tried using a call service node with {} or with
{ “volume_level”: {{flow.var_name.attributes.volume_level}}} but they don’t work

here’s my flow:

[{"id":"7c674098.d55c5","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"a7d38d89.b4e6c","type":"inject","z":"7c674098.d55c5","name":"on","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":130,"y":140,"wires":[["34b58a78.b34546"]]},{"id":"34b58a78.b34546","type":"api-current-state","z":"7c674098.d55c5","name":"get g mini volume","server":"46a5f96a.e810e8","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"media_player.family_room_speaker","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"pv","override_data":"flow","blockInputOverrides":false,"x":310,"y":140,"wires":[["22aacf64.76577"]]},{"id":"22aacf64.76577","type":"api-call-service","z":"7c674098.d55c5","name":"set vol to 2","server":"46a5f96a.e810e8","version":1,"debugenabled":false,"service_domain":"media_player","service":"volume_set","entityId":"media_player.family_room_speaker","data":"{\"entity_id\":\"media_player.family_room_speaker\",\"volume_level\":\"0.2\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":530,"y":140,"wires":[["d3a8f8df.d3d6c8"]]},{"id":"a22baf68.c7974","type":"api-current-state","z":"7c674098.d55c5","name":"g mini","server":"46a5f96a.e810e8","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"media_player.family_room_speaker","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":730,"y":140,"wires":[["16a8ad2d.3c71e3","65c9b612.874e88"]]},{"id":"16a8ad2d.3c71e3","type":"api-call-service","z":"7c674098.d55c5","name":"set original vol","server":"46a5f96a.e810e8","version":1,"debugenabled":false,"service_domain":"media_player","service":"volume_set","entityId":"media_player.family_room_speaker","data":"{    \"volume_level\": {{flow.pv.attributes.volume_level}}}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":920,"y":140,"wires":[["7b97a19e.ae5b9"]]},{"id":"7b97a19e.ae5b9","type":"api-current-state","z":"7c674098.d55c5","name":"g mini","server":"46a5f96a.e810e8","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"media_player.family_room_speaker","state_type":"str","state_location":"","override_payload":"none","entity_location":"PrevVolume","override_data":"flow","blockInputOverrides":false,"x":1170,"y":140,"wires":[["e99c160e.9b2f98"]]},{"id":"65c9b612.874e88","type":"debug","z":"7c674098.d55c5","name":"msg1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"data.attributes.volume_level","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":60,"wires":[]},{"id":"e99c160e.9b2f98","type":"debug","z":"7c674098.d55c5","name":"msg2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1150,"y":60,"wires":[]},{"id":"d3a8f8df.d3d6c8","type":"delay","z":"7c674098.d55c5","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":600,"y":220,"wires":[["a22baf68.c7974"]]},{"id":"46a5f96a.e810e8","type":"server","name":"Home Assistant","addon":true}]

the initial volume is set to 0.1, msg1 returns 0.2 and msg2 returns 0.2 and I’m expecting msg2 to return 0.1

What do you think?

1 Like

This is part of my flow that does the same.

[{"id":"be398e2b.a6e67","type":"ha-wait-until","z":"7c674098.d55c5","name":"","server":"4bbca37b.1700ec","outputs":2,"entityId":"{{device}}","entityIdFilterType":"exact","property":"state","comparator":"is","value":"idle","valueType":"str","timeout":"10","timeoutType":"num","timeoutUnits":"seconds","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":1640,"y":400,"wires":[["165479c9.c11d16"],["165479c9.c11d16"]]},{"id":"d2b56f3e.a2323","type":"delay","z":"7c674098.d55c5","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1480,"y":400,"wires":[["be398e2b.a6e67"]]},{"id":"165479c9.c11d16","type":"api-call-service","z":"7c674098.d55c5","name":"","server":"4bbca37b.1700ec","version":1,"debugenabled":false,"service_domain":"media_player","service":"volume_set","entityId":"{{device}}","data":"{\"entity_id\":\"{{device}}\",\"volume_level\":\"{{prev_volume}}\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1870,"y":400,"wires":[[]]},{"id":"77b87f10.c2e03","type":"api-call-service","z":"7c674098.d55c5","name":"Speak message","server":"4bbca37b.1700ec","version":1,"debugenabled":false,"service_domain":"tts","service":"cloud_say","entityId":"media_player.nedervaningen","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1320,"y":400,"wires":[["d2b56f3e.a2323"]]},{"id":"5a89cddb.d13e94","type":"api-call-service","z":"7c674098.d55c5","name":"","server":"4bbca37b.1700ec","version":1,"debugenabled":false,"service_domain":"media_player","service":"volume_set","entityId":"{{device}}","data":"{\"entity_id\":\"{{device}}\",\"volume_level\":\"{{volume}}\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1070,"y":400,"wires":[["77b87f10.c2e03"]]},{"id":"a8b675d1.1f1558","type":"change","z":"7c674098.d55c5","name":"","rules":[{"t":"set","p":"prev_volume","pt":"msg","to":"data.attributes.volume_level","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":400,"wires":[["5a89cddb.d13e94"]]},{"id":"1faa079f.2dc188","type":"api-current-state","z":"7c674098.d55c5","name":"Get previous volume","server":"4bbca37b.1700ec","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"{{device}}","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":560,"y":400,"wires":[["a8b675d1.1f1558"]]},{"id":"4bbca37b.1700ec","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Not sure why you would need it to be a flow variable. But I think the issue is that you don’t have the" "

When you see your json like this when you open it, something is wrong.

After editing it to and clicking done:

and opening it again you see the formatting is “correct” again.

and the red border is gone from here:
image

Hi
trying to copy your flow, can you let me know what was in your set.msg_payload?

edit: just saw your flow … thanks
Thanks
Fred

Here you have a node that let you set the announcement volume and after the voice message is played the initial device volume level is restored.
If you want to give a try here you can find more details about the node:
https://flows.nodered.org/node/node-red-google-notify

1 Like

If you send a TTS message to a google device while it is casting Spotify from a cell phone for example, the connected device will disconnect, the TTS message will play then the music will not continue playback.
Have you experienced this?

There a couple of threads around like this one TTS Announcements, Google cast, Music - Issues and workaround