Using Node-Red for Google Home TTS announcements and other stuff eWeLink

It says “Something to say” but its not very loud so don’t think its 100% volume.

Lots of stuff get put in to the debug window.

Can you export that entire debug output to a text file or something ?

I think this is all of it expanded:

07/12/2020, 17:11:44node: 8f341729.aa98d8
msg.payload : undefined
undefined
07/12/2020, 17:11:45node: 8f341729.aa98d8
msg.payload : undefined
undefined
07/12/2020, 17:11:45node: 8f341729.aa98d8
msg.payload : null
null
07/12/2020, 17:11:45node: 8f341729.aa98d8
msg.payload : Object
object
mediaSessionId: 1
playbackRate: 1
playerState: "IDLE"
currentTime: 0
supportedMediaCommands: 274447
volume: object
level: 1
muted: false
activeTrackIds: array[0]
media: object
contentId: "https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=en&q=Something%20to%20say"
contentType: "audio/mp3"
streamType: "BUFFERED"
metadata: object
metadataType: 0
title: "tts"
images: array[1]
0: object
url: "https://nodered.org/node-red-icon.png"
mediaCategory: "AUDIO"
currentItemId: 1
extendedStatus: object
playerState: "LOADING"
media: object
contentId: "https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=en&q=Something%20to%20say"
contentType: "audio/mp3"
streamType: "BUFFERED"
metadata: object
metadataType: 0
title: "tts"
images: array[1]
0: object
mediaCategory: "AUDIO"
mediaSessionId: 1
repeatMode: "REPEAT_OFF"
07/12/2020, 17:11:45node: 8f341729.aa98d8
msg.payload : undefined
undefined
07/12/2020, 17:11:46node: 8f341729.aa98d8
msg.payload : Object
object
mediaSessionId: 1
playbackRate: 1
playerState: "PLAYING"
currentTime: 0
supportedMediaCommands: 274447
volume: object
level: 1
muted: false
activeTrackIds: array[0]
media: object
contentId: "https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=en&q=Something%20to%20say"
contentType: "audio/mp3"
streamType: "BUFFERED"
metadata: object
metadataType: 0
title: "tts"
images: array[1]
0: object
mediaCategory: "AUDIO"
duration: 1.464
tracks: array[1]
0: object
trackId: 1
type: "AUDIO"
breakClips: array[0]
breaks: array[0]
currentItemId: 1
items: array[1]
0: object
itemId: 1
media: object
contentId: "https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=en&q=Something%20to%20say"
contentType: "audio/mp3"
streamType: "BUFFERED"
metadata: object
metadataType: 0
title: "tts"
images: array[1]
0: object
mediaCategory: "AUDIO"
duration: 1.464
autoplay: true
activeTrackIds: array[0]
orderId: 0
repeatMode: "REPEAT_OFF"
07/12/2020, 17:11:47node: 8f341729.aa98d8
msg.payload : Object
object
mediaSessionId: 1
playbackRate: 1
playerState: "PLAYING"
currentTime: 1.074105
supportedMediaCommands: 274447
volume: object
level: 1
muted: false
activeTrackIds: array[0]
currentItemId: 1
repeatMode: "REPEAT_OFF"
07/12/2020, 17:11:47node: 8f341729.aa98d8
msg.payload : undefined
undefined
07/12/2020, 17:11:47node: 8f341729.aa98d8
msg.payload : Object
object
mediaSessionId: 1
playbackRate: 1
playerState: "IDLE"
currentTime: 0
supportedMediaCommands: 274447
volume: object
level: 1
muted: false
currentItemId: 1
idleReason: "FINISHED"

you can hover mose over right side of debug and icon will appear that says copy value, if you click it it will copy value to clipboard.

can you copy value of volume object from debug?

or inject this payload

[{"id":"5b00ab01.0fe374","type":"inject","z":"8d22ae29.7df6d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"type\":\"Volume\",\"volume\":100}","payloadType":"json","x":100,"y":2340,"wires":[[]]}]

There is like four main things it puts in to the debug:

{"mediaSessionId":1,"playbackRate":1,"playerState":"IDLE","currentTime":0,"supportedMediaCommands":274447,"volume":{"level":1,"muted":false},"activeTrackIds":[],"media":{"contentId":"https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=en&q=Something%20to%20say","contentType":"audio/mp3","streamType":"BUFFERED","metadata":{"metadataType":0,"title":"tts","images":[{"url":"https://nodered.org/node-red-icon.png"}]},"mediaCategory":"AUDIO"},"currentItemId":1,"extendedStatus":{"playerState":"LOADING","media":{"contentId":"https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=en&q=Something%20to%20say","contentType":"audio/mp3","streamType":"BUFFERED","metadata":{"metadataType":0,"title":"tts","images":[{"url":"https://nodered.org/node-red-icon.png"}]},"mediaCategory":"AUDIO"},"mediaSessionId":1},"repeatMode":"REPEAT_OFF"}
{"mediaSessionId":1,"playbackRate":1,"playerState":"PLAYING","currentTime":0,"supportedMediaCommands":274447,"volume":{"level":1,"muted":false},"activeTrackIds":[],"media":{"contentId":"https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=en&q=Something%20to%20say","contentType":"audio/mp3","streamType":"BUFFERED","metadata":{"metadataType":0,"title":"tts","images":[{"url":"https://nodered.org/node-red-icon.png"}]},"mediaCategory":"AUDIO","duration":1.464,"tracks":[{"trackId":1,"type":"AUDIO"}],"breakClips":[],"breaks":[]},"currentItemId":1,"items":[{"itemId":1,"media":{"contentId":"https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=en&q=Something%20to%20say","contentType":"audio/mp3","streamType":"BUFFERED","metadata":{"metadataType":0,"title":"tts","images":[{"url":"https://nodered.org/node-red-icon.png"}]},"mediaCategory":"AUDIO","duration":1.464},"autoplay":true,"activeTrackIds":[],"orderId":0}],"repeatMode":"REPEAT_OFF"}
{"mediaSessionId":1,"playbackRate":1,"playerState":"PLAYING","currentTime":1.107177,"supportedMediaCommands":274447,"volume":{"level":1,"muted":false},"activeTrackIds":[],"currentItemId":1,"repeatMode":"REPEAT_OFF"}
{"mediaSessionId":1,"playbackRate":1,"playerState":"IDLE","currentTime":0,"supportedMediaCommands":274447,"volume":{"level":1,"muted":false},"currentItemId":1,"idleReason":"FINISHED"}

That one errors

try this as i had not used capitals

[{"id":"5b00ab01.0fe374","type":"inject","z":"8d22ae29.7df6d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"type\":\"VOLUME\",\"volume\":100}","payloadType":"json","x":100,"y":2340,"wires":[[]]}]

That works and changes the volume on the Google Home Mini.

I also tried 10 and that turns it down again.

ok what do you want as default, i will create function and post here when done, may find time tomorrow.

I think 35% as default, she’s not too loud at that level, when asking her regular things like what time is and what’s the weather like.

One last test

can you add cast node where debug is and then inject, does it speak at 70 then set volume to 35?

[{"id":"5b00ab01.0fe374","type":"inject","z":"8d22ae29.7df6d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"type\":\"VOLUME\",\"volume\":70}","payloadType":"json","x":50,"y":2420,"wires":[["ba0e539b.3fb8a8","af17f34a.768af8"]]},{"id":"ba0e539b.3fb8a8","type":"trigger","z":"8d22ae29.7df6d","name":"","op1":"{\"type\":\"TTS\",\"text\":\"Something to say\"}","op2":"{\"type\":\"VOLUME\",\"volume\":35}","op1type":"json","op2type":"json","duration":"500","extend":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":280,"y":2460,"wires":[["af17f34a.768af8"]]},{"id":"af17f34a.768af8","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":600,"y":2420,"wires":[]}]

Nope, it seems to turn it up then turn it down and then say the TTS.

can you change the time setting in the trigger to 2 seconds

5 seconds works with that particular phrase “Something to say”.

However longer TTS announcements may need more time.

Try this one do not reuse any of the old one.

[{"id":"5b00ab01.0fe374","type":"inject","z":"8d22ae29.7df6d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":70,"y":2420,"wires":[["ba0e539b.3fb8a8","af17f34a.768af8"]]},{"id":"ba0e539b.3fb8a8","type":"trigger","z":"8d22ae29.7df6d","name":"","op1":"{\"type\":\"TTS\",\"text\":\"Something to say\"}","op2":"{\"type\":\"VOLUME\",\"volume\":35}","op1type":"json","op2type":"json","duration":"5","extend":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":260,"y":2460,"wires":[["af17f34a.768af8"]]},{"id":"af17f34a.768af8","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":600,"y":2420,"wires":[]}]

I will add 2 seconds per word.

That one doesn’t change the volume either way at all it just says the TTS.

I takes a few seconds for it to connect to the Home speaker before it even starts speaking, that is why 5 seconds worked on that last test.

It was long enough for it to connect say the phrase at the increased volume and then for it to lower the volume again.

I was experimenting with the meta data to see if Volume could be passed
try this

[{"id":"5b00ab01.0fe374","type":"inject","z":"8d22ae29.7df6d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":70,"y":2420,"wires":[["ba0e539b.3fb8a8","af17f34a.768af8"]]},{"id":"ba0e539b.3fb8a8","type":"trigger","z":"8d22ae29.7df6d","name":"","op1":"{\"type\":\"TTS\",\"text\":\"Something to say\",\"metadata\":{\"volume\":70}}","op2":"{\"type\":\"VOLUME\",\"volume\":35}","op1type":"json","op2type":"json","duration":"5","extend":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":260,"y":2460,"wires":[["af17f34a.768af8"]]},{"id":"af17f34a.768af8","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":600,"y":2420,"wires":[]}]

Same it says the TTS but the volume is not changed either way at all.

I am seeing a lot of these Undefined messages in the debug, even though it works and says the TTS on the speaker.

OK it was worth a shot, i will add a volume to function.
The castv2 from docs "output the current google cast device platform state or cast application state " so i would not worry when running just disable the debug output by pressing the button, you can also view info in the node status. add this debug to your cast nodes and run a tts

[{"id":"af17f34a.768af8","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload.idleReason","statusType":"msg","x":600,"y":2420,"wires":[]}]

OK I’ve added that debug node to all the castv2 nodes.