Home Assistant Community

Send random messages to google home?

#1

Has anyone setup sending random messages or quotes to the google home?

Right now I have a message sent to one of my google homes when my daughter gets home saying “welcome home”. But it gets boring after awhile. Is there a way to have a data base of messages and Node red would pick a random one every time it was triggered?

#2

Yes i currently have this set up with Node Red. In the “announce” section i utilize the HomeAssistant “template” with the below snippet.

{{ [
"Welcome Home Domenic",
"Domenic you are home, we missed you so much!",
"Welcome home Master",
"Hey there Domenic Welcome Home!",
"Domenic can not hide from the system. Welcome home.",
"Just a quick announcement. Domenic has arrived!",
"My systems are picking up the presence of additional humans. Domenic has been identified as home."
 ] | random }}

1 Like
#3

Thanks so much. Going to have so much fun with this. lol

1 Like
#4
[{"id":"7589f533.bcd29c","type":"function","z":"e5243fcc.3bd4d","name":"Alexa random messages","func":"msg.payload = {};\nmsg.payload.data = {};\nmsg.payload.data.entity_id = {};\nmsg.payload.data.message ={};\n\nvar myArray = [\n  \"The entertainment system has been primed, and is ready to go... Enjoy yourself, and don't forget the snacks \",\n  \"hey sunshine, go put your feet up and watch a good movie\",\n  \"Marmalade will hold the fort, you go and enjoy yourself\",\n  \"See ya soon\",\n  \"Go on then bugger off, I'll sit and mumble to myself \",\n  \"The entertainment system is all set up, go have fun\"\n];\n\nvar randomItem = myArray[Math.floor(Math.random()*myArray.length)];\n\nmsg.payload.data.entity_id = \"media_player.annaka_s_echo_dot\";\nmsg.payload.data.message = randomItem;\n\n\nreturn msg;\n","outputs":1,"noerr":0,"x":611,"y":96,"wires":[[]]}]

This is a function node I use for Alexa to say random quotes

#5

I’m using the Alexa as a Media Player component setup and I’m trying to get your function working. How do you get the message to play from a particular Alexa? I changed your media player to the media player that I want to say the message. Also when I manually run the function the debugger will give me a random message showing it works but I cant seem to get it to flow to the Alexa device.

Thanks,

#6

Have you made sure the Entity ID’s match in the function node (line 17) and the Alexa Service node.

#7

I double checked line 17 and it’s correct what is the Alexa Service node?