This is a tutorial how you can control your devices by using your voice in your own language…
All this can be also triggered by Google Now.
Requirements:
- An android phone
- Tasker
- Autovoice
Setup Tasker:
Configuration File
First I like to setup several thing, so I made a task, that I only need to run once… I’m putting my host, password and my devices in here. (When a device changes, then I only need to change it on 1 place, and all the other tasks will change as well).
So a config task would be like this in tasker:
- Variable set: %HASS_PSW To ?api=xxxxx
- Variable set: %HASS_HOST To http://yourhost:8123
- Variable set: %HASS_SERVICE to %HASS_HOST/api/services/
- Variable set: %HASS_STATE to %HASS_HOST/api/states/
Then your devices with your correct ID of HASS eg:
- Variable set: %HASS_WOL to switch.wol
- Variable set: %HASS_TOPLIGHT to light.living_toplight
- Variable set: %HASS_SIDELIGHT to light.living_sidelight
After creating this, you need to run this task, so Tasker knows all the variables and remember it.
In the autovoice plugin:
- Activate Google Now integration, if you want integration with Google Now
- Set your language: General settings > Default Recognize Settings > Language Settings > Language (Also Language Code)
- Don’t forget to enable in your android settings, the accessibility for Autovoice
In tasker:
Create a general profile
- Create a new profile
- Choose Event > Plugin > Autovoice Recognize
- Checkmark Event Behaviour
- As command filter use: (?<task>.+) my (?<device>.+)
(beware of typo mistakes)
- Checkmark regex
Create a new task
- Work with if-else function
Example 1: task to turn off/turn on task with if-else statements inside the task
I prefer to use just the If statement instead of the if-else statement, because I can collapse my code…
- If %task ~ turn on AND %device ~ living lights (turn on living lights)
- Variable set: %service to light/turn_on
HTTP Post:
- Service port: %HASS_SERVICE%service%HASS_PSW
- In data / file: {"entity_id":""%HASS_TOPLIGHT","brightness":"255"}
- content/type: application/JSON
- End if
- If %task ~ turn off AND %device ~ living lights (turn off living lights)
- Variable set: %service to light/turn_off
HTTP Post:
- Service port: %HASS_SERVICE%service%HASS_PSW
- In data / file: {"entity_id":""%HASS_TOPLIGHT"}
- content/type: application/JSON
- End if
...
Example 2: Dim lights task
Create first a profile with the following command:
dim (?<device>.+) to (?<percentage>.+)%
Then your task:
- If %device ~ living lights
- Variable set: %service to light/turn_on
HTTP Post:
- Service port: %HASS_SERVICE%service%HASS_PSW
- In data / file: {"entity_id":""%HASS_TOPLIGHT","brightness":"%percentage"}
- content/type: application/JSON
- End if
Commands
Above a little example to turn on or turn off things, but you can create also other profiles likes:
- dim (?<device>.+) to (?<percentage>.+)%
- activate (?<scene>.+) mode
- ....
You only need to change data and attributes…
The beauty of this, is that I can use Google now, so I can use Google AI to recognize my speech, and when I say a command by saying OK Google, it will also send it to my tasker autovoice…
Those examples are in english, but I on my phone I’ve all the commands in dutch. It works great… But I couldnt post it here in dutch, because nobody would understand
I’ve not yet made a video demo of integration of HASS.
But I’ve an 2 year old demo of tasker + autovoice for automation my phone (a small part what my personal assistent can do): https://www.youtube.com/watch?v=DsF2PelmX_E and here a demo in dutch (3 year old video): https://www.youtube.com/watch?v=8OAo8ehBAzU
Now I will also integrate HASS in my personal assistent
PS: if you are not familiar with tasker, follow me… I’ve made more then 100 tutorials and my Google+ community counts around 6600 subscribers