Created
February 1, 2024 02:09
-
-
Save Didgeridrew/b5ba80dcbb6fc0eab7842a6698980074 to your computer and use it in GitHub Desktop.
HA - Trigger Contexts Template Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias: zTest Context Templates | |
description: "" | |
trigger: | |
- platform: state | |
entity_id: | |
- switch.kitchen_lightswitch | |
to: "on" | |
variables: | |
id: "{{trigger.to_state.context.id}}" | |
parent: "{{ trigger.to_state.context.parent_id }}" | |
user: "{{ trigger.to_state.context.user_id }}" | |
context: | |
Manual: "{{ parent is none and user is none }}" | |
Auto: "{{ id is not none and parent is not none }}" | |
UI: "{{ id is not none and user is not none }}" | |
type: "{{ (context.items()|selectattr(1, 'eq', True)|first)[0] }}" | |
condition: | |
- condition: template | |
value_template: "{{ type in ['UI', 'Manual' ]}}" | |
action: | |
- service: persistent_notification.create | |
data: | |
message: | | |
Type: {{type}} | |
Context: {{ context }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment