Voice Assistants: Working with Alexa and Google’s custom entities in Node-red

Voice Assistants: Working with Alexa and Google's custom entities in Node-red

So for those of you who have been following my blog, you’ll know that I’ve been able to create my own entities in Google Home and Alexa. This has allowed me to not only control entities that aren’t specifically “working with XYZ” but also to create routines as well. I know natively you can do it in their respective ecosystems, but being able to go full custom is definitely an advantage. The routines that I can create are infinitely more complex and not to mention quick to debug and construct. here is an example of our bedtime routine. If you’ve seen the other blog posts you’ll see how relatively straight forward it is to set up. We have both Google Home and Amazon Alexa in our household, and I wanted to make sure that I had the same entities created in both. It’s irritating to the wrong assistant to turn on XYZ and doesn’t bode well for the WAF.

I wanted to write a brief post to highlight the differences between working with the custom entities from Alexa as well as Google. Both can be used to the same effect, but there’s a couple of fundamental differences in working with them in node-red. I’ll deal with the most simplest form i.e. a switch

In Alexa, when you create a custom switch it’s output is boolean. This makes it relatively easy to control. With the help of a switch node with boolean inputs you can turn the switch on according to a true or false output. See below for the nodes required. This is simple enough to implement.

Alexa flow
Alexa flow
Alexa switch node
Alexa switch node

 

In Google Home, when you create a custom switch, it’s output is different to that of Alexa. It sends a full JSON message which we then have to scrape. You’ll see under the parameters that we have online: true or false, and on: true and false. It’s the latter that we need to determine the correct switch operation. Once we’ve scraped the output correctly, we then have to go a step further to modify the resultant payload to turn the switch on or off. Here, I like to convert the payload to match the Alexa one so I am able to combine the two. See below for the full node breakdown.

Google Home flow
Google Home flow
attributes from Google Home bridge
attributes from Google Home bridge

 

Google Home Switch Node
Google Home Switch Node

 

Google Home change node
Google Home change node

As promised, here’s the combined node that helps to keep both voice assistants in check!

Alexa Google Combo
Alexa Google Combo

As you can see the differences are small but significant. Hoping this quick post will help someone else to configure their systems quickly and efficiently. Again, if you’ve not seen the posts about how to create these custom entities, I’d refer you back to these: Google Home and Alexa.

If you enjoyed this type of content and would be interested in sharing your own solutions, tips and tricks with like minded people perhaps you’d consider joining our facebook group. The aim of this group will hopefully be more show and tell rather than support, but that’s not to say we can’t lend a helping hand 🙂

https://www.facebook.com/groups/386238285944105

Happy New Year!

Leave a Reply