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

How it looks now:

I’m adding Comments with documentation so others will be able to follow what we have done.

Question:

The function for the MIOS IN monitoring still has the volume specified individually for each device is that right?

   let sensors={
    "Kitchen:Patio Door:Tripped":{
        "ips":"192.168.0.16|192.168.0.19",
        "message":["Patio Door Closed","Patio Door Opened"],
        "volume":60
    },
    "Porch:Front Door:Tripped":{
        "ips":"192.168.0.16|192.168.0.19",
        "message":["Front Door Closed","Front Door Opened"],
        "volume":60
    },
    "Porch:Letterbox:Tripped":{
        "ips":"192.168.0.16|192.168.0.19",
        "message":["null","Letter box Opened"],
        "volume":60
    },
    "Back Garden:Garden Gate:Tripped":{
        "ips":"192.168.0.16|192.168.0.21",
        "message":["Garden Gate Closed","Garden Gate Opened"],
        "volume":60
    },
    "Lounge:Fireplace:Status":{
        "ips":"192.168.0.16",
        "message":["Turning Off Fireplace","Turning On Fireplace"],
        "volume":60
    }
}

if you omit volume then the global default is used or hard coded default

you can also attach the delay and debug of the mios monitoring to the other mios node so only one mios required.

OK I am removing the hard coded volume levels from this function.

I’ve tested with them removed and the Global level does work.

image

Like that…

yes thats correct

Here is the final flow code, with the instructions in the Comment labels, for the CastV2 integration.

Flow Code you can Import:

[{"id":"2c1c608.171caa","type":"tab","label":"Google-Home-TTS-CastV2","disabled":false,"info":""},{"id":"bf3403b3.7926","type":"function","z":"2c1c608.171caa","name":"function for MIOS device status","func":"let sensors={\n    \"Kitchen:Patio Door:Tripped\":{\n        \"ips\":\"192.168.0.16|192.168.0.19\",\n        \"message\":[\"Patio Door Closed\",\"Patio Door Opened\"],\n    },\n    \"Porch:Front Door:Tripped\":{\n        \"ips\":\"192.168.0.16|192.168.0.19\",\n        \"message\":[\"Front Door Closed\",\"Front Door Opened\"],\n    },\n    \"Porch:Letterbox:Tripped\":{\n        \"ips\":\"192.168.0.16|192.168.0.19\",\n        \"message\":[\"null\",\"Letter box Opened\"],\n    },\n    \"Back Garden:Garden Gate:Tripped\":{\n        \"ips\":\"192.168.0.16|192.168.0.21\",\n        \"message\":[\"Garden Gate Closed\",\"Garden Gate Opened\"],\n    },\n    \"Lounge:Fireplace:Status\":{\n        \"ips\":\"192.168.0.16\",\n        \"message\":[\"Turning Off Fireplace\",\"Turning On Fireplace\"],\n    }\n}\nif(sensors[msg.topic]){\nlet sensor = sensors[msg.topic];\nmsg.payload = (msg.payload === true || msg.payload === 1) ? 1 : 0;\nif(sensor[\"message\"][msg.payload] !== \"null\"){\nmsg.payload = {\n    \"message\": sensor[\"message\"][msg.payload],\n    \"ip\": sensor[\"ips\"],\n    \"volume\": sensor[\"volume\"]\n    }\nmsg.sensor = true;\nreturn msg;\n}else{\n    return;\n}\n}else{\n    return;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":350,"y":360,"wires":[["de79989a.a52818"]]},{"id":"de79989a.a52818","type":"function","z":"2c1c608.171caa","name":"function for TTS","func":"var IPS = msg.payload.ip.split(\"|\");\nvar message = msg.payload.message;\nvar ttsVolume = msg.payload.volume || global.get(\"ttsVolumeDefault\") || 60;\nfor (var i in IPS) { \n    //msg.ttsVolume = true;\n    msg.payload = {\"type\":\"VOLUME\",\"volume\":ttsVolume,\"ip\":IPS[i]};\n    node.send([null,msg]);\nmsg.payload = {\n    type: \"TTS\",\n    text: message,\n    language: \"En-gb\",\n    ip: IPS[i],\n    }\nmsg.iptts = IPS[i];\nnode.send([null, [msg]]);\n}\nif(!msg.sensor){\nmsg.payload = \"ok\"; // the response message\nreturn [msg];\n}else{\n return;\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","x":240,"y":240,"wires":[["3be8a007.b440f"],["961c039f.d9511"]]},{"id":"624339ce.70a148","type":"http in","z":"2c1c608.171caa","name":"http request from Vera scene","url":"sceneTrigger","method":"get","upload":false,"swaggerDoc":"","x":160,"y":140,"wires":[["de79989a.a52818"]]},{"id":"3be8a007.b440f","type":"http response","z":"2c1c608.171caa","name":"http response","statusCode":"200","headers":{},"x":400,"y":40,"wires":[]},{"id":"961c039f.d9511","type":"switch","z":"2c1c608.171caa","name":"IP Switch","property":"payload.ip","propertyType":"msg","rules":[{"t":"eq","v":"192.168.0.16","vt":"str"},{"t":"eq","v":"192.168.0.19","vt":"str"},{"t":"eq","v":"192.168.0.20","vt":"str"},{"t":"eq","v":"192.168.0.21","vt":"str"},{"t":"eq","v":"192.168.0.24","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":440,"y":200,"wires":[["bcb2ede6.8e6be"],["ae3e1796.60de38"],["f0ddf7c4.b12bb8"],["3b8e7ccb.9fd924"],["f8a77c67.f07e1"]]},{"id":"bcb2ede6.8e6be","type":"castv2-sender","z":"2c1c608.171caa","name":"Lounge Mini .16","connection":"6f8783fb.3dd50c","spotifyAccessToken":"","spotifyAccessTokenExpiration":"","spotifyDeviceName":"","x":740,"y":160,"wires":[["fe70ae7a.b52e4","bf3a7cec.7b0c2"]],"icon":"node-red-contrib-cast/google-home-mini2.svg"},{"id":"ae3e1796.60de38","type":"castv2-sender","z":"2c1c608.171caa","name":"Kitchen Home .19","connection":"84b64104.c6bd5","spotifyAccessToken":"","spotifyAccessTokenExpiration":"","spotifyDeviceName":"","x":750,"y":260,"wires":[["b9e34b7e.af5118","d781600d.1fe4e"]],"icon":"node-red-contrib-cast/google-home1.svg"},{"id":"f0ddf7c4.b12bb8","type":"castv2-sender","z":"2c1c608.171caa","name":"Bathroom Mini .20","connection":"eefe01fb.d0bec","spotifyAccessToken":"","spotifyAccessTokenExpiration":"","spotifyDeviceName":"","x":750,"y":360,"wires":[["4cdb0217.44aedc","686877d7.4b8df8"]],"icon":"node-red-contrib-cast/google-home-mini2.svg"},{"id":"3b8e7ccb.9fd924","type":"castv2-sender","z":"2c1c608.171caa","name":"Masterbed Mini .21","connection":"7f5d6c3c.415914","spotifyAccessToken":"","spotifyAccessTokenExpiration":"","spotifyDeviceName":"","x":750,"y":460,"wires":[["bc00f492.b58de8","7231cd7f.49e0b4"]],"icon":"node-red-contrib-cast/google-home-mini2.svg"},{"id":"f8a77c67.f07e1","type":"castv2-sender","z":"2c1c608.171caa","name":"Bedroom 2 Home .24","connection":"292a4ac3.634916","spotifyAccessToken":"","spotifyAccessTokenExpiration":"","spotifyDeviceName":"","x":760,"y":560,"wires":[["de3f625d.eb99d","5b5dc80a.94bce8"]],"icon":"node-red-contrib-cast/google-home1.svg"},{"id":"fe70ae7a.b52e4","type":"debug","z":"2c1c608.171caa","name":"Debug","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"        (payload.idleReason = \"FINISHED\" ? \"Done\" : \"\")\t  & \" | \" & $moment().format(\"ddd HH:mm:ss\")\t","statusType":"jsonata","x":910,"y":60,"wires":[]},{"id":"b9e34b7e.af5118","type":"debug","z":"2c1c608.171caa","name":"Debug","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"        (payload.idleReason = \"FINISHED\" ? \"Done\" : \"\")\t  & \" | \" & $moment().format(\"ddd HH:mm:ss\")\t","statusType":"jsonata","x":910,"y":200,"wires":[]},{"id":"4cdb0217.44aedc","type":"debug","z":"2c1c608.171caa","name":"Debug","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"        (payload.idleReason = \"FINISHED\" ? \"Done\" : \"\")\t  & \" | \" & $moment().format(\"ddd HH:mm:ss\")\t","statusType":"jsonata","x":910,"y":300,"wires":[]},{"id":"bc00f492.b58de8","type":"debug","z":"2c1c608.171caa","name":"Debug","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"        (payload.idleReason = \"FINISHED\" ? \"Done\" : \"\")\t  & \" | \" & $moment().format(\"ddd HH:mm:ss\")\t","statusType":"jsonata","x":910,"y":400,"wires":[]},{"id":"de3f625d.eb99d","type":"debug","z":"2c1c608.171caa","name":"Debug","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"        (payload.idleReason = \"FINISHED\" ? \"Done\" : \"\")\t  & \" | \" & $moment().format(\"ddd HH:mm:ss\")\t","statusType":"jsonata","x":910,"y":500,"wires":[]},{"id":"8ecba8b2.49f138","type":"mios-in","z":"2c1c608.171caa","name":"MIOS IN","server":"db098590.052cd8","item":"","exact":false,"x":100,"y":360,"wires":[["bf3403b3.7926","41377e30.60137"]]},{"id":"de0f2132.c86fc","type":"comment","z":"2c1c608.171caa","name":"MIOS IN Debug Info Only","info":"This debug output can be used to monitor your Vera devices for their state / status changes, so you can work out what is the correct \"Item\" to be used in the \"function for MIOS device Status\" function node.\n\nSee \"MIOS IN device status\" comment for more information.","x":150,"y":420,"wires":[]},{"id":"d1a19516.6a44b8","type":"comment","z":"2c1c608.171caa","name":"HTTP Requests in from Vera","info":"Example 1:\n\nhttp://192.168.0.4:1880/sceneTrigger?message=Alarm%20Carbon%20Monoxide%20Detected&ip=192.168.0.16\n\nSays \"Alarm Carbon Monoxide Detected\" and sends it to one Google Home speaker for TTS announcement, with the IP address ending in .16\n\nExample 2:\n\nhttp://192.168.0.4:1880/sceneTrigger?message=Alarm%20Carbon%20Monoxide%20Detected&ip=192.168.0.16|192.168.0.19\n\nSends the same TTS message but to two Google Home speakers with the IP's ending in .16 and .19\n\n192.168.0.4 is the IP address of the node red instance.","x":160,"y":100,"wires":[]},{"id":"6b0de92b.8c47b8","type":"comment","z":"2c1c608.171caa","name":"MIOS IN device status","info":"In the \"function for MIOS device status\" this is where you specify the Vera devices you want to have monitored and linked to Google Home TTS. \n\nFor example when a door contact sensor is opened or closed.\n\nIn the function, under the \"let sensors\" section is where you specify them. \n\nHere is an example for my kitchen door.\n\n\"Kitchen:Patio Door:Tripped\" is the Item used to monitor this particular Vera device, to see if it is Tripped (1) or not tripped (0).\n\nYou can use the \"MIOS IN Debug Info Only\" output, to monitor your Vera devices whilst changing their state, to see what is the correct Item to use.\n\nThis is the code used for my kitchen door in the \"let sensors\" section of the function.\n\nThe TTS message spoken is either \"Patio Door Closed\" or \"Patio Door Opened\" and I am sending it to one Google Home speaker with the LAN IP ending in .16\n\n    \"Kitchen:Patio Door:Tripped\":{\n        \"ips\":\"192.168.0.16\",\n        \"message\":[\"Patio Door Closed\",\"Patio Door Opened\"],\n\nTo send the TTS announcement to more than one Google Home speaker simply add its IP address like this:\n\n \"Kitchen:Patio Door:Tripped\":{\n        \"ips\":\"192.168.0.16|192.168.0.19\",\n        \"message\":[\"Patio Door Closed\",\"Patio Door Opened\"],\n\nHere is another example for my Fireplace turning on and off which is just an appliance plug. You can see the item is slightly different and using \"Lounge:Fireplace:Status\"\n\n\"Lounge:Fireplace:Status\":{\n        \"ips\":\"192.168.0.16\",\n        \"message\":[\"Turning Off Fireplace\",\"Turning On Fireplace\"],\n\nAgain the \"MIOS IN Debug Info Only\" output can be used to monitor your Vera devices state changing, so you can work out the correct Item to use in the function. \n\nIn this example I only wanted a TTS announcement when my Letterbox is opened NOT closed. So a \"null\" is added in to the message portion.\n\n\"Porch:Letterbox:Tripped\":{\n        \"ips\":\"192.168.0.16|192.168.0.19\",\n        \"message\":[\"null\",\"Letter box Opened\"],\n\nTo change the default volume levels see the \"Specify & Change Volume Levels\" comment.","x":200,"y":320,"wires":[]},{"id":"1c00911c.dbcccf","type":"comment","z":"2c1c608.171caa","name":"Home Speakers LAN IP's","info":"In the Switch specify each IP address of your Google Home speakers in the correct order.","x":450,"y":140,"wires":[]},{"id":"fb0d4947.9be478","type":"comment","z":"2c1c608.171caa","name":"CastV2 for each Home Speaker","info":"Create two CastV2 nodes for each of your Google Home speakers specifying their LAN IP address, the port number for each is the same, which is 8009. \n\nThe links from the \"IP Switch\" node must be in the correct order, so the IP address specified in the \"IP Switch\" node output, matches up to the correct CastV2 node with the same IP address etc. ","x":730,"y":120,"wires":[]},{"id":"bf3a7cec.7b0c2","type":"function","z":"2c1c608.171caa","name":"After TTS lower Volume","func":"if(msg.payload && msg.payload.idleReason && msg.payload.idleReason === \"FINISHED\"){\n    msg.payload={\"type\":\"VOLUME\",\"volume\":(global.get(\"ttsVolumeReset\") || 35)};\n    return msg;\n}\nreturn;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1010,"y":160,"wires":[["331cc661.d1453a"]]},{"id":"331cc661.d1453a","type":"castv2-sender","z":"2c1c608.171caa","name":"Lounge Mini .16","connection":"6f8783fb.3dd50c","spotifyAccessToken":"","spotifyAccessTokenExpiration":"","spotifyDeviceName":"","x":1220,"y":160,"wires":[[]],"icon":"node-red-contrib-cast/google-home-mini2.svg"},{"id":"46266f73.79e6a","type":"comment","z":"2c1c608.171caa","name":"function for HTTP Commands","info":"On line 11, you can specifty the language e.g. English - Great Britian.\n\nlanguage: \"En-gb\",\n\nTo change the default volume levels see the \"Specify & Change Volume Levels\" comment.","x":200,"y":200,"wires":[]},{"id":"d781600d.1fe4e","type":"function","z":"2c1c608.171caa","name":"After TTS lower Volume","func":"if(msg.payload && msg.payload.idleReason && msg.payload.idleReason === \"FINISHED\"){\n    msg.payload={\"type\":\"VOLUME\",\"volume\":(global.get(\"ttsVolumeReset\") || 35)};\n    return msg;\n}\nreturn;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1010,"y":260,"wires":[["98993b95.546b58"]]},{"id":"98993b95.546b58","type":"castv2-sender","z":"2c1c608.171caa","name":"Kitchen Home .19","connection":"84b64104.c6bd5","spotifyAccessToken":"","spotifyAccessTokenExpiration":"","spotifyDeviceName":"","x":1230,"y":260,"wires":[[]],"icon":"node-red-contrib-cast/google-home1.svg"},{"id":"e6ba51a7.28a89","type":"comment","z":"2c1c608.171caa","name":"Lowers Volume after TTS","info":"These functions are used to lower the volume level on the Google Home speakers afer the TTS announcement has finished.\n\nTo change the volume levels see the \"Specify & Change Volume Levels\" comment.","x":990,"y":120,"wires":[]},{"id":"ae9a4e19.f7c77","type":"inject","z":"2c1c608.171caa","name":"Click to Change Volume Levels","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":190,"y":540,"wires":[["8cecb82b.e479c8"]]},{"id":"8cecb82b.e479c8","type":"change","z":"2c1c608.171caa","name":"Specify Volume Levels","rules":[{"t":"set","p":"ttsVolumeDefault","pt":"global","to":"60","tot":"num"},{"t":"set","p":"ttsVolumeReset","pt":"global","to":"35","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":540,"wires":[[]]},{"id":"79c350db.2b8c1","type":"comment","z":"2c1c608.171caa","name":"Specify & Change Volume Levels","info":"Use the \"Specify Volume Levels\" Change node, to set the global volume level the TTS announcement will play at, this is \"ttsVolumeDefault\" the default level is 60%\n\nAnd specify the volume level to return to after the TTS announcement has finished, this is \"ttsVolumeReset\" the default level is 35%\n\nThen click the Inject node named \"Click to Change Volume Levels\" to action the change.","x":170,"y":500,"wires":[]},{"id":"686877d7.4b8df8","type":"function","z":"2c1c608.171caa","name":"After TTS lower Volume","func":"if(msg.payload && msg.payload.idleReason && msg.payload.idleReason === \"FINISHED\"){\n    msg.payload={\"type\":\"VOLUME\",\"volume\":(global.get(\"ttsVolumeReset\") || 35)};\n    return msg;\n}\nreturn;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1010,"y":360,"wires":[["a507d574.4d0478"]]},{"id":"a507d574.4d0478","type":"castv2-sender","z":"2c1c608.171caa","name":"Bathroom Mini .20","connection":"eefe01fb.d0bec","spotifyAccessToken":"","spotifyAccessTokenExpiration":"","spotifyDeviceName":"","x":1230,"y":360,"wires":[[]],"icon":"node-red-contrib-cast/google-home-mini2.svg"},{"id":"7231cd7f.49e0b4","type":"function","z":"2c1c608.171caa","name":"After TTS lower Volume","func":"if(msg.payload && msg.payload.idleReason && msg.payload.idleReason === \"FINISHED\"){\n    msg.payload={\"type\":\"VOLUME\",\"volume\":(global.get(\"ttsVolumeReset\") || 35)};\n    return msg;\n}\nreturn;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1010,"y":460,"wires":[["2d9427f6.1714c8"]]},{"id":"2d9427f6.1714c8","type":"castv2-sender","z":"2c1c608.171caa","name":"Masterbed Mini .21","connection":"7f5d6c3c.415914","spotifyAccessToken":"","spotifyAccessTokenExpiration":"","spotifyDeviceName":"","x":1230,"y":460,"wires":[[]],"icon":"node-red-contrib-cast/google-home-mini2.svg"},{"id":"5b5dc80a.94bce8","type":"function","z":"2c1c608.171caa","name":"After TTS lower Volume","func":"if(msg.payload && msg.payload.idleReason && msg.payload.idleReason === \"FINISHED\"){\n    msg.payload={\"type\":\"VOLUME\",\"volume\":(global.get(\"ttsVolumeReset\") || 35)};\n    return msg;\n}\nreturn;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1010,"y":560,"wires":[["f23ad709.f3cc28"]]},{"id":"f23ad709.f3cc28","type":"castv2-sender","z":"2c1c608.171caa","name":"Bedroom 2 Home .24","connection":"292a4ac3.634916","spotifyAccessToken":"","spotifyAccessTokenExpiration":"","spotifyDeviceName":"","x":1240,"y":560,"wires":[[]],"icon":"node-red-contrib-cast/google-home1.svg"},{"id":"acbe0a8d.7e7578","type":"debug","z":"2c1c608.171caa","name":"Vera Debug","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":510,"y":420,"wires":[]},{"id":"41377e30.60137","type":"delay","z":"2c1c608.171caa","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":350,"y":420,"wires":[["acbe0a8d.7e7578"]]},{"id":"6f8783fb.3dd50c","type":"castv2-connection","z":"","name":"Lounge Mini","target":"","host":"192.168.0.16","port":"8009"},{"id":"84b64104.c6bd5","type":"castv2-connection","z":"","name":"Kitchen Home","target":"","host":"192.168.0.19","port":"8009"},{"id":"eefe01fb.d0bec","type":"castv2-connection","z":"","name":"Bathroom Mini","target":"","host":"192.168.0.20","port":"8009"},{"id":"7f5d6c3c.415914","type":"castv2-connection","z":"","name":"Masterbed Mini","target":"","host":"192.168.0.21","port":"8009"},{"id":"292a4ac3.634916","type":"castv2-connection","z":"","name":"Bedroom 2 Home","target":"","host":"192.168.0.24","port":"8009"},{"id":"db098590.052cd8","type":"mios-server","z":"","name":"Vera-Plus","host":"192.168.0.12","port":"3480"}]

Or you can import the attached .json file.

flows-Google-TTS.zip (4.1 KB)

Thank you once again to @ElCid for his expertise. :grin:

I’ve updated the first post with the needed information.

With all the debug nodes in the flow disabled and turned off and no debug nodes selected in the debug window, I am seeing lots of these messages.

Not sure if it is something to be concerned about or not.

Its coming from the function nodes in between the two CastV2 nodes.

It is comming from those undefined payloads. It wont break anything but is messy.
Try this function 3

[{"id":"150701a9.eddee6","type":"function","z":"66b3988b.4a2ea8","name":"","func":"if(msg.payload && msg.payload.idleReason && msg.payload.idleReason === \"FINISHED\"){\n    msg.payload={\"type\":\"VOLUME\",\"volume\":(global.get(\"ttsVolumeReset\") || 35)};\n    return msg;\n}\nreturn;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":820,"y":140,"wires":[["be455479.e024e8"]]}]

That seems to have done the trick, the messages aren’t appearing now.

Thanks.

@ElCid

Do you have a ChromeCast Video device ?

Wondering what else we might be able to do with this new CastV2. Maybe some transport control buttons in the Home Remote dashboard app as they don’t currently support any ChromeCast integration.

I’ve got all of them to work except for the “Queue_Next” and “Queue_Prev” don’t work.

And the GET ones don’t seem to do anything.

Flow code:

[{"id":"6ce33703.8fccc8","type":"tab","label":"ChromeCast Controls","disabled":false,"info":""},{"id":"68ae3a2f.665ed4","type":"function","z":"6ce33703.8fccc8","name":"Pause","func":"msg =\n{\n  payload: {\n    type: \"PAUSE\"\n  }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":290,"y":120,"wires":[["1b2db6c5.2d90e9"]]},{"id":"4e0c4f55.85fc9","type":"inject","z":"6ce33703.8fccc8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":120,"wires":[["68ae3a2f.665ed4"]]},{"id":"2c4f858f.5ff04a","type":"function","z":"6ce33703.8fccc8","name":"Volume","func":"msg =\n{\n  payload: {\n    type: \"VOLUME\",\n    volume: 100 // 0 to 100\n  }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":300,"y":420,"wires":[["1b2db6c5.2d90e9"]]},{"id":"7ff95f18.2f87a","type":"inject","z":"6ce33703.8fccc8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":420,"wires":[["2c4f858f.5ff04a"]]},{"id":"1b2db6c5.2d90e9","type":"castv2-sender","z":"6ce33703.8fccc8","name":"Lounge ChromeCast .18","connection":"be825ad1.83fa78","spotifyAccessToken":"","spotifyAccessTokenExpiration":"","spotifyDeviceName":"","x":610,"y":60,"wires":[["efefc407.a1a508"]],"icon":"node-red-contrib-cast/cast-cli3.svg"},{"id":"8ad75d10.7982b","type":"function","z":"6ce33703.8fccc8","name":"Play","func":"msg =\n{\n  payload: {\n    type: \"PLAY\"\n  }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":290,"y":60,"wires":[["1b2db6c5.2d90e9"]]},{"id":"9c96381b.3c9fe8","type":"inject","z":"6ce33703.8fccc8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":60,"wires":[["8ad75d10.7982b"]]},{"id":"2025ceb7.b5b522","type":"function","z":"6ce33703.8fccc8","name":"Stop","func":"msg =\n{\n  payload: {\n    type: \"STOP\"\n  }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":290,"y":180,"wires":[["1b2db6c5.2d90e9"]]},{"id":"2a1e3dcb.34e8c2","type":"inject","z":"6ce33703.8fccc8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":180,"wires":[["2025ceb7.b5b522"]]},{"id":"296482f2.583e0e","type":"function","z":"6ce33703.8fccc8","name":"Mute","func":"msg =\n{\n  payload: {\n    type: \"MUTE\"\n  }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":290,"y":480,"wires":[["1b2db6c5.2d90e9"]]},{"id":"637bffa6.2e08d","type":"inject","z":"6ce33703.8fccc8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":480,"wires":[["296482f2.583e0e"]]},{"id":"f6930b8b.d2d9b8","type":"function","z":"6ce33703.8fccc8","name":"UnMute","func":"msg =\n{\n  payload: {\n    type: \"UNMUTE\"\n  }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":300,"y":540,"wires":[["1b2db6c5.2d90e9"]]},{"id":"107de48a.51397b","type":"inject","z":"6ce33703.8fccc8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":540,"wires":[["f6930b8b.d2d9b8"]]},{"id":"9a6b1018.2374","type":"function","z":"6ce33703.8fccc8","name":"Seek","func":"msg =\n{\n  port: 8009,\n  payload: {\n    type: \"SEEK\",\n    time: 100 // Time to seek to in seconds\n  }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":290,"y":240,"wires":[["1b2db6c5.2d90e9"]]},{"id":"932fa4f4.5e4d28","type":"inject","z":"6ce33703.8fccc8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":240,"wires":[["9a6b1018.2374"]]},{"id":"f699f6ae.800698","type":"function","z":"6ce33703.8fccc8","name":"Queue_Next","func":"msg =\n{\n  payload: {\n    type: \"QUEUE_NEXT\"\n  }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":310,"y":300,"wires":[["1b2db6c5.2d90e9"]]},{"id":"67f2becf.d15ec","type":"inject","z":"6ce33703.8fccc8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":300,"wires":[["f699f6ae.800698"]]},{"id":"e7ecab6d.6eae28","type":"function","z":"6ce33703.8fccc8","name":"Queue_Prev","func":"msg =\n{\n  payload: {\n    type: \"QUEUE_PREV\"\n  }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":310,"y":360,"wires":[["1b2db6c5.2d90e9"]]},{"id":"39be5dc7.4497f2","type":"inject","z":"6ce33703.8fccc8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":360,"wires":[["e7ecab6d.6eae28"]]},{"id":"9194b09b.bce33","type":"function","z":"6ce33703.8fccc8","name":"Close App","func":"msg =\n{\n  payload: {\n    type: \"CLOSE\"\n  }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":310,"y":600,"wires":[["1b2db6c5.2d90e9"]]},{"id":"c8294262.6e00c","type":"inject","z":"6ce33703.8fccc8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":600,"wires":[["9194b09b.bce33"]]},{"id":"b9da4111.9425d","type":"function","z":"6ce33703.8fccc8","name":"GET Volume","func":"msg =\n{\n  payload: {\n    type: \"GET_VOLUME\"\n  }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":770,"y":140,"wires":[["1b2db6c5.2d90e9"]]},{"id":"9cc1c6a6.695a68","type":"inject","z":"6ce33703.8fccc8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":570,"y":140,"wires":[["b9da4111.9425d"]]},{"id":"efefc407.a1a508","type":"debug","z":"6ce33703.8fccc8","name":"Debug","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"        (payload.idleReason = \"FINISHED\" ? \"Done\" : \"\")\t  & \" | \" & $moment().format(\"ddd HH:mm:ss\")\t","statusType":"jsonata","x":810,"y":60,"wires":[]},{"id":"3f1c9a35.35e216","type":"function","z":"6ce33703.8fccc8","name":"GET Status","func":"msg =\n{\n  payload: {\n    type: \"GET_CAST_STATUS\"\n  }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":770,"y":200,"wires":[["1b2db6c5.2d90e9"]]},{"id":"cb92555c.9753c8","type":"inject","z":"6ce33703.8fccc8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":570,"y":200,"wires":[["3f1c9a35.35e216"]]},{"id":"be825ad1.83fa78","type":"castv2-connection","z":"","name":"Lounge ChromeCast","target":"","host":"192.168.0.18","port":"8009"}]

Interesting I’ve just discovered you can also send TTS announcements to the ChromeCast Video device on the TV.

Although it kills and stops what ever was already playing on the ChromeCast before the TTS was sent to it.

No not a google user, except android(and they are slowly poisoning that)

I think you would need to be playing from a playlist for QUEUE_NEXT to work.

the apps it works with.
DefaultMediaReceiver
GooglePlayMusic - media control only
GogolePlayMovies - media control only
Netflix - media control only
Spotify - media control only
TuneIn - media control only
YouTube

so you should be able to link to youtube media

That’s a shame, maybe Santa will bring you a new ChromeCast with Google TV !

I’ve not bought one of the new Google TV ChromeCast’s yet.

I have a 4K Fire TV stick in the living room as I prefer Youtube with a menu GUI and remote control.

All the other TV’s just have a regular ChromeCast video device, which is what my daughter users to cast her phone and iPad to the TVs.

All I tried was using the Youtube app on my phone and I added a few videos in to the QUEUE.

But pressing the Queue Next Inject didn’t make it skip and start playing the next video in the queue.

I haven’t figured out the different apps yet for this CastV2.

Specifying the app doesn’t seem to work either for Queue Next.

msg =
{
  payload: {
    app: "YouTube",
    type: "QUEUE_NEXT"
  }
}
return msg;

“Error: Invalid request: INVALID_COMMAND”

It says you don’t need to specify app anyway for “Media Commands” and Queue Next is a media command.

“Media commands are listed below. These tend to be global to most media apps. For any app supported by this module, these should be supported. You do not need to include an app with these as the node will attempt to join any active sessions for supported apps automatically.”

Seems its the command itself it doesn’t like for some reason.

Definitely doesn’t work, just started playing a music playlist of videos off YouTube. Next_Queue doesn’t skip to the next music video.

Not supported

1 Like

I’m just reading that now, found it before you posted.

Bill over on the Home Remote forum just told me he has added support for Google Cast devices. So I’ll be using that now instead, rather than these CastV2 node playback controls.

As of version 0.2.17 of the original node-red-contrib-cast, it is working again now.

So you can now choose either of these different Cast nodes to use, up to you…

Think I’ll be sticking with the new CastV2 node as it seems more reliable with the TTS announcements as previously stated and with the newly designed flow, we have more functionality.

Thanks for the clear explanation how to use TTS with castV2. It works perfect only when I play TuneIn and TTS message appears the music stops. Is it possible to resume the stream after TTS?
You may be able to read the current stream and save it in a variable and start stream again after TTS. I am not familiar with node red. You may know a solution.

Best Home Automation shopping experience. Shop at getvera!

© 2021 Ezlo Innovation, All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules