Control Homeassistant With Autovoice

by RuneP in Circuits > Raspberry Pi

1290 Views, 3 Favorites, 0 Comments

Control Homeassistant With Autovoice

screenshot_2018_03_21_18_48_05.png

I use this addon with hass.io

https://github.com/notoriousbdg/hassio-addons

Making the Flow:

import flow.png

Open node red and import from clipboard:

[{"id":"165e858.8828e7b","type":"http in","z":"2dc8d53.130392a","name":"Request","url":"/autovoicedemo","method":"get","upload":false,"swaggerDoc":"","x":65,"y":24,"wires":[["a6f33781.dad458","1250379d.83f9e8"]]},{"id":"1250379d.83f9e8","type":"debug","z":"2dc8d53.130392a","name":"debug node1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":323,"y":55,"wires":[]},{"id":"a6f33781.dad458","type":"function","z":"2dc8d53.130392a","name":"","func":"//use line 3 for autovoice tasker\n//use line 4 for testing in a browser\nvar temp = msg.req.query.text;// autovoice\n//var temp = msg.payload.data; //web http://user:pass@ipadresse/autovoicedemo?turn%20on%demo\ntemp = temp.toLowerCase();\ntemp = temp.replace(\"temp\",\"test\");\ntemp = temp.replace(\"tester\",\"test\");\ntemp = temp.replace(\"lights\",\"light\");\ntemp = temp.replace(\"lamp\",\"light\");\nmsg.payload = temp;\nreturn msg;","outputs":1,"noerr":0,"x":140,"y":98,"wires":[["2c0447e0.50cb88"]]},{"id":"2c0447e0.50cb88","type":"change","z":"2dc8d53.130392a","name":"","rules":[{"t":"set","p":"intext","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":185,"y":181,"wires":[["8463e1b9.4ed3","4ed32b9.be556d4"]]},{"id":"4ed32b9.be556d4","type":"function","z":"2dc8d53.130392a","name":"setting response","func":"temp = msg.intext;\ntemp = temp.replace(\"turn\",\"turning\");\ntemp = temp.replace(\"switch\",\"switching\");\nmsg.payload = \"ok, \" + temp;\nreturn msg;","outputs":1,"noerr":0,"x":500,"y":137,"wires":[["57010e61.2ce46"]]},{"id":"57010e61.2ce46","type":"http response","z":"2dc8d53.130392a","name":"","statusCode":"","headers":{},"x":701,"y":122,"wires":[]},{"id":"8463e1b9.4ed3","type":"switch","z":"2dc8d53.130392a","name":"on or off","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"off","vt":"str"},{"t":"cont","v":"on","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":213,"y":293,"wires":[["55d30093.6d9cb"],["2608b174.32f8ce"]]},{"id":"55d30093.6d9cb","type":"change","z":"2dc8d53.130392a","name":"setting service to off","rules":[{"t":"set","p":"service","pt":"msg","to":"turn_off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":401,"y":251,"wires":[["2cb5822.a6e7f7e"]]},{"id":"2608b174.32f8ce","type":"change","z":"2dc8d53.130392a","name":"setting service to on","rules":[{"t":"set","p":"service","pt":"msg","to":"turn_on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":407,"y":309,"wires":[["2cb5822.a6e7f7e"]]},{"id":"2cb5822.a6e7f7e","type":"switch","z":"2dc8d53.130392a","name":"light select","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"demo","vt":"str"},{"t":"cont","v":"test","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":612,"y":291,"wires":[["b1728ef8.80775"],["8e3fc65e.9e8f78"]]},{"id":"b1728ef8.80775","type":"change","z":"2dc8d53.130392a","name":"setting data to test switch1","rules":[{"t":"set","p":"data","pt":"msg","to":"switch.bod_oppe_bod","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":834,"y":237,"wires":[["515757f2.53b618"]]},{"id":"8e3fc65e.9e8f78","type":"change","z":"2dc8d53.130392a","name":"setting data to test switch1","rules":[{"t":"set","p":"data","pt":"msg","to":"switch.bod_oppe_bod","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":833,"y":341,"wires":[["515757f2.53b618"]]},{"id":"515757f2.53b618","type":"template","z":"2dc8d53.130392a","name":"Formatting for hass.io","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":" { \"data\": {\"entity_id\": \"{{data}}\" },\n \"service\": \"{{service}} \" \n }\n","output":"json","x":1075,"y":279,"wires":[["ce858d.40ab1a7","a1c6af5b.870cd"]]},{"id":"ce858d.40ab1a7","type":"debug","z":"2dc8d53.130392a","name":"debug node2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1237,"y":194,"wires":[]}]

Add Homeassistant Palette If You Dont Have It

add palette.png
hass node.png

Add homeassistant palette like in the pictures

You need to set this up first time..

Let me know if i have to add steps for that

Add Homeassistant Node

homeassistant node.png
hass node settings.png

Add home assistant node like in the pictures.

Connect it to the formatting node

Edit the node to:

Server: homeassistant

Domain: homeassistant, light or switch. (i use homeassistant since it can do both)

You need to edit the setting data switches to match entity_id of the lights you want to integrate.

Adding more lights is easy.. just add them under add item in the switch node

Making the Tasker Task

Open tasker and create a new task

first choose plugin -> autovoice and recognize

Then add a http get:

under server:port add: http//user:pass@[ip-to-nodered]:[port]

under path add: autovoicedemo

attributes: text=avcomm

User/Agent: application/json

if you use ssl and have problems try checking trust any certificate

Then add a flash %HTTPD

and finally a say %HTTP

Run the task and check if it works..

If you need me to add more info or steps let me know