Tasker
Home
Direct Purchase
Download
TaskerNet
Home Automation
Usage Examples
Pre-made Projects
FAQs
Guides
Reviews
Wiki
Plugin List
Forum
Forum/Support
Legacy Forum
Userguide (5.0+)
Index: en es fr zh
1 Page: en
More
Join
AutoApps
Developers
History
Privacy Policy
Release Notes
Next Version
Feature Requests
Report Issues
Patreon

Home Assistant Integration In Tasker

You can both control Home Assistant and trigger Tasker profiles based on Home Assistant events.

Table Of Contents

Initial Setup

On the device with Home Assistant

  • Open the Profile screen, scroll all the way to the bottom to Long-Lived Access Tokens, generate a Token and save it. You'll need to enter it into Tasker later.
  • Open the Add-on Store, install the File editor add-on and enable the Show in sidebar option
  • Open the File editor add-on on the side-bar and edit the /config/configuration.yaml file
  • Add the following lines to the end of the file and save it:
    rest_command:
      tasker:
        url: 'http://{{ip_address}}:{{port}}/{{path}}'
        method: POST
        verify_ssl: false
        payload: "{{ event }}"
        content_type:  'application/json; charset=utf-8'
        
        
    template:
      - trigger:
          platform: event
          event_type: tasker_event
        sensor:
          - name: Tasker State
            state: "{{trigger.event.data.state}}"
    	
  • Use the File Editor Add-on to create the /config/blueprints/automation/tasker folder and in it create a new file called tasker.yaml
  • Write the following text in the file and save:
    blueprint:
      name: Tasker HTTP Request
      description: Call Tasker when a device changes state
      domain: automation
      input:
        ip_address:
          name: IP Address
          description:  The IP Address of the Android device Tasker is running on
          default: "192.168."
          selector:
            text:
                type: text
        port:
          name: Port
          description:  The port the Tasker device is listening on (usually 1821)
          default: "1821"
          selector:
            text:
                type: number
        path:
          name: Path
          description:  The path in the HTTP Request event condition that the Tasker device is listening on (usually 'home_assistant')
          default: "home_assistant"
          selector:
            text:
                type: text
        target_devices:
          name: Devices
          description:  The devices that should trigger the request
          selector:
            entity:
              multiple: true
    
    trigger:
      - platform: state
        entity_id: !input target_devices
    
    action:
        service: rest_command.tasker
        data:
          ip_address: !input ip_address
          port: !input port
          path: !input path
          event: |
            {
              'device_id':'{{trigger.entity_id}}',
              'device_name':'{{state_attr(trigger.entity_id,'friendly_name')}}',
              'from':'{{trigger.from_state.state}}',
              'to':'{{trigger.to_state.state}}'
            }
    				
  • Go into Settings > Top-right Menu > Restart Home Assistant so that the new configuration will be applied.
  • Wait until it restarts

Tasker

  • Import this project into Tasker and follow the prompts, entering the token you generated before.
  • Optionally, you can use this project to generate super-realistic voice messages on your Home Media Devices. If you want to do so, please also import this project.
  • You are now ready to use Home Assistant with Tasker!

Ways Tasker Intereacts with Home Assistant

Controlling Devices In Home Assistant From Tasker

The Tasker project above provides several actions that allows you to control lights, scenes, play YouTube videos and more.
For example, the HASS Toggle Light task allows you turn a light on or off (or toggle it) based on the Parameters. Check the HASS Pick And Toggle Light task for an example.

Triggering Automations In Home Assistant From Tasker

Use the HASS Trigger Event task in Tasker to trigger the tasker_event event in Home Assistant.
You can then create an Automation in Home Assistant (Settings > Automations & Scenes > Create Automation) that, for example, turns a light on if that event's value is set to flaslight on.
Use the Tasker State entity in Home Assistant as your automation trigger and set the To field to the value that you want to trigger that automation.

Triggering Tasker Tasks From Home Assistant (Requires Tasker 6.2 or above. Sign up for the beta if needed.)

Use the Tasker HTTP Request blueprint in Home Assistant (Settings > Automations & Scenes > Blueprints > Tasker HTTP Request) to easily trigger the Receive Home Assistant Status Changes profile in the Tasker project that you imported.
When configuring the blueprint, make sure to select all the devices that you want to trigger the profile with.
For example, if you want a light to trigger the Tasker profile any time it's toggled, add it to the blueprint.
The task in the Receive Home Assistant Status Changes profile will call a task with the following values:
  • Task Name: "State Changed " followed by the name of the device whose status changed in Home Assistant
  • Parameter 1: The state the device was in, before the status change
  • Parameter 2: The state the device was left on, after the status change
For example, if a light called Bedroom was changed from off to on, then the following Task in Tasker would be called:
  • Task Name: State Changed Bedroom
  • Parameter 1: off
  • Parameter 2: on
In that task (named Bedroom in the example) you can do whatever you want, like updating the status of a quick setting tile for example.

Triggering Tasker Tasks From Google Assistant, including Google Home (Requires Tasker 6.2 or above. Sign up for the beta if needed.)

You can use Home Assistant as a middle-man to allow you to trigger your Tasker tasks from Google Assistant from any device that runs Google Asssistant (your phone, Google Home, Android Auto, etc).
This is an example of how to toggle Do Not Disturb mode on your phone from Google Assistant, but you can change it to do anything you want.
  • Start by following the directions in the Triggering Tasker Tasks From Home Assistant section above.
  • Follow the directions to enable Google Assistant integration in Home Assistant here.
  • In Home Assistant follow the directions to create an Input Select helper here.
  • Name the helper Do Not Disturb and give it an icon you like (like mdi:minus-circle for example).
  • In the Options section add the options:
    • On
    • Off
    • Priority
    • Alarms
  • Save the Helper.
  • In Home Assistant go into Settings > Voice assistants > Expose tab > click Expose Entities button at the bottom.
  • Select the Do Not Disturb helper you created before.
  • In the Google Home App on your Android device check that the new Do Not Disturb device has been added to your device list (if not, refresh your devices)
  • Open the device and check that the 4 Do Not Disturb states are available for that device.
  • In Home Assistant, add the Do Not Disturb device to the list of devices that trigger the Receive Home Assistant Status Changes profile mentioned in the Triggering Tasker Tasks From Home Assistant section above.
  • Import this task into Tasker. Notice that it is called State Changed Do Not Disturb. This follows the name pattern mentioned in the Triggering Tasker Tasks From Home Assistant section above.
Now if you say Hey Google set Do Not Disturb to Alarms for example, your phone's Do Not Disturb setting should be set to Alarms only mode!
You can create as many helpers with as many states as you want now, to trigger different tasks in Tasker on your Android device! Remember that %par2 in the task will always contain the state that the Helper device was changed to!