Google Home with Node Red
Taking advantage of the fact that many of us have this type of Smart Speakers, today I want to show you how to give a more personal touch to our Home Assistant.
In today's topic we are going to use the Google Home or Google Mini or any of its variants, as an acoustic notifier for Home Assistant and what we can do, for example:
- Use it as a siren for our alarm system. Home Assistant Bwalarm
- Let us know when the main door opens or when it closes.
- And any maneuver that crosses your mind, that warns when the blinds are closed, the irrigation is turned on, etc...
As you already know, we already have some basic tutorials on Node-Red so you can see its use and possibilities, installation of Node Red, Schedule Scheduler.
Well first of all, you have to have your Google Home or variant configured in Home Assistant, for this you have to go to the integrations section and add Google Cast.
Once installed, we are going to use the Call-Service node
We drag it to our Flow and double-click on it to enter its configuration.
Let's see what data we have to select:
- Name – We assign the name we want.
- Server – we select Home Assistant
- Domain – media_player
- Service – play_media will cause you to play an audio file previously uploaded to your folder.
- Entity Id – media_player. and the name that Home Assistant has assigned to your smart speaker.
- Data – {“entity_id”:”media_player.NOMBREASIGNADO”,”media_content_id”:”https://TUDIRECCION.duckdns.org:8123/local/sound/POLICE.mp3″,”media_content_type”:”music”}
REMEMBER TO UPLOAD THE FILE VIA FTP TO THE FOLDER www/sound/ CREATE THESE FOLDER IF YOU DO NOT HAVE THEM.
The file that I have put is a siren, to carry out the test you can put a manual trigger to see if it works, for them you must use the INJECT node
And in the properties you have to select the following:
From the drop-down menu we select string and complete with ON, so that it sends the start command.
Once we have the two nodes linked, click on Deploy and click on the inject that is now called on and your smart speaker should play the audio.
But what if I want it to read a message instead of playing a sound? So we make the following configurations of the Call-Service node.
As you can see here we have changed the Domain and we have selected tts, as Service google_say, the Entity is the same, since we want to use the same smart speaker, and in data we put the following:
{“message”:”activating alarm.”} in this way it reproduces the text that is enclosed in quotes “activating alarm” here you can put what you are interested in reading.
As you can see, it is simple and quick to do, the truth is that it is a joy when it tells you that the alarm is connected.
What do you think? easy right?
We continue trying to make simple and short examples, we will have time to complicate everything a little more, but first we have to understand how it works Node Red.
More coming soon, if you have questions leave your comment so we can help you, thank you.
If you have a request on how to perform a task in Node Red comment
You can also see how to install Alexa one Node Red
Thanks for the explanation, sorry but how do I create the folder where I upload the files?
Hello, you have to have access to the file system of your Home Assistant, either by ftp, sftp or samba, you have to create a folder called www and then another folder called sound and paste the audio file in this folder, like this So the path would be www/sound/soundname.mp3.
Good afternoon. I am new in Node-Red. When I go to “inject” it tells me “Successfully injected ON” but it gives me an “API Error” error and no sound is heard. However, the Google Home Mini works correctly from a Lovelace. What am I doing wrong?. Thank you
Hello, make sure the entity_id, media_player.ASSIGNAME is correctly selected