Control Sony TV with Google Home & IFTTT without public IP/domain
An easy to setup flow using Google Home, IFTTT and Webhook Relay to control your TV using Node-RED without exposing it to the internet.
Webhook Relay will be acting as a message broker between Google Home with IFTTT and Node-RED. Naturally, let's configure it first. Got to buckets page and create a new bucket called 'gactions'. In the bucket details page, you should see 'Default public endpoint' URL that starts with https://my.webhookrelay.com/v1/webhooks/...
. Keep this tab open, you will need to copy that URL into IFTTT.
Configure Google Home & IFTTT
Head to IFTTT, then to your applets and click on "New Applet". Search for "Google Assistant". When choosing a trigger pick 'Say a simple phrase' for our scenario. You can try other ones later for different automation. Now, in 'What do you want to say?' section type 'turn the TV on' or something similar. Whatever you want basically. Populate other fields and pick your response phrase. Click "Create trigger".
For the action service, choose "webhook". In the URL part, take the 'Default public endpoint' from step 1 (that starts with https://my.webhookrelay.com/v1/webhooks/...
). Choose method to "POST", set Content Type to 'application/json' and set body to:
{
"action": "tv_on"
}
Once done, click "Create Action". You can now repeat the same process for more commands such as turning the TV off, mute, lower the sound and so on. I have configured three applets in total to send webhooks to the same endpoint:
To turn it off:
{
"action": "tv_off"
}
To mute it:
{
"action": "tv_mute"
}
Configuring Webhook Relay credentials
Get authentication tokens and set them to the node-red-contrib-webhookrelay
node. In the "Buckets" field, add our "gactions" bucket which we created previously.
Once deployed, you should see "Connected" near the Webhook Relay node.
Configuring TV & WOL nodes
To configure WOL node you will need to know your TV MAC address. You can either find it from the router or from TV network settings. Same goes for IP.
[{"id":"e8757f5a.d3e63","type":"tab","label":"google home","disabled":false,"info":""},{"id":"cc70fafa.341f8","type":"tv-bravia-put","z":"e8757f5a.d3e63","device":"76b6f1d1.5f92e8","name":"","action":"Mute","x":650,"y":460,"wires":[[]]},{"id":"8e6631f0.9f4e5","type":"tv-bravia-put","z":"e8757f5a.d3e63","device":"76b6f1d1.5f92e8","name":"turn off TV","action":"Sleep","x":670,"y":300,"wires":[[]]},{"id":"430ed221.c4bb24","type":"wake on lan","z":"e8757f5a.d3e63","mac":"","host":"","name":"turn on TV","x":670,"y":380,"wires":[]},{"id":"bc073cef.500598","type":"webhookrelay","z":"e8757f5a.d3e63","buckets":"gactions","x":130,"y":220,"wires":[["e98a21eb.74d69"]]},{"id":"e98a21eb.74d69","type":"function","z":"e8757f5a.d3e63","name":"extract body","func":"\nreturn {\n payload: msg.payload.body\n};","outputs":1,"noerr":0,"x":330,"y":220,"wires":[["b46e91fe.5820d"]]},{"id":"a575fe2b.abd5c","type":"switch","z":"e8757f5a.d3e63","name":"","property":"payload.action","propertyType":"msg","rules":[{"t":"eq","v":"tv_off","vt":"str"},{"t":"eq","v":"tv_on","vt":"str"},{"t":"eq","v":"tv_mute","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":310,"y":340,"wires":[["8e6631f0.9f4e5"],["430ed221.c4bb24"],["cc70fafa.341f8"]]},{"id":"b46e91fe.5820d","type":"json","z":"e8757f5a.d3e63","name":"","property":"payload","action":"","pretty":false,"x":500,"y":220,"wires":[["a575fe2b.abd5c"]]},{"id":"76b6f1d1.5f92e8","type":"tv-bravia","z":"","name":"lounge","address":"","port":"80","debug":false}]