Skip to content

Trigger State Change

Profile → Plugin → TaskerHA → HA On Trigger State

Fires a Tasker profile whenever an entity (or a specific attribute) changes state in Home Assistant. Uses the WebSocket connection for real-time updates.

WebSocket required

Enable the WebSocket toggle in the TaskerHA app. Without it this profile will never fire.

How to use

  1. In Tasker, create a new profile and tap PluginTaskerHAHA On Trigger State.
  2. Use the entity picker to add one or more entities (supports domain filtering and fuzzy search).
  3. Optionally configure the filter fields below.

Filter fields

FieldDescription
FromOnly fire when the previous state matches this value (e.g. off). Leave empty to match any state.
ToOnly fire when the new state matches this value (e.g. on). Leave empty to match any state.
ForOnly fire if the entity was in the previous state for at least this duration (HH:MM:SS).
Target attributeWatch a specific attribute instead of the main state (e.g. brightness, color_mode). When set, %ha_from and %ha_to contain the attribute values, not the entity state.
Entity picker with domain filter
Entity picker — filter by domain and search by ID
Main config screen with filter fields
Filter fields — Target attribute, From, To, and For
Attribute variable mapping screen
Attribute mappings — assign attributes to %ha_attr_1%ha_attr_10

You can use Tasker variables in any filter field.

Multiple entities

Add multiple entities to a single profile. All are monitored over a single shared WebSocket subscription. Use %ha_entity in your task to determine which one fired.

Config per entity

By default all filter settings apply to every entity equally. Toggle Config per entity to give each entity its own From, To, For, and Target attribute settings.

Attribute variable mapping

Map specific attribute values to fixed Tasker variables %ha_attr_1 through %ha_attr_10, so you don't have to parse %ha_attrs JSON every time.

  1. Tap Load attributes to fetch the current attribute list from Home Assistant.
  2. Attributes shared across all configured entities appear under Shared; entity-specific ones appear under each entity.
  3. Assign a slot number (1–10). After the profile fires, %ha_attr_N contains that attribute's value.

Variables set when the profile fires

VariableDescription
%ha_entityentity_id of the entity that triggered the profile.
%ha_fromPrevious state of the entity (e.g. off). When a Target attribute is set, contains the previous attribute value instead.
%ha_toNew state of the entity (e.g. on). When a Target attribute is set, contains the new attribute value instead.
%ha_forHow long the entity was in the previous state (HH:MM:SS). Empty if not applicable.
%ha_entitiesComma-separated list of all entity IDs configured in this profile.
%ha_attrsJSON object of all attributes on the entity for the new state.
%ha_attr_1%ha_attr_10Values of attributes mapped via Attribute variable mapping. Only populated for slots you configured.
%ha_rawRaw JSON of the full state-change event from Home Assistant.
%errError code. 0 means no error.
%errmsgHuman-readable error message, often followed by a Java exception for details.

Error codes

CodeDescription
0No error.
9999Unknown error. Check %errmsg for the Java exception.

Examples

Fire when the front door opens:

FieldValue
Entitybinary_sensor.front_door
Fromoff
Toon

React when a light's color mode changes:

FieldValue
Entitylight.living_room
Target attributecolor_mode

%ha_from will be the old color mode (e.g. color_temp), %ha_to will be the new one (e.g. xy).

Map brightness to a variable:

In Attribute variable mapping, assign brightness to slot 1. After the profile fires, %ha_attr_1 contains the current brightness without any JSON parsing.

Released under the MIT License.