Skip to content

Instantly share code, notes, and snippets.

@nistvan86
Last active January 24, 2021 18:12
Show Gist options
  • Save nistvan86/f15307b48edc532f18c90e8e1b500207 to your computer and use it in GitHub Desktop.
Save nistvan86/f15307b48edc532f18c90e8e1b500207 to your computer and use it in GitHub Desktop.
IKEA Tradfri 2-Key On/Off Light Switch Handler
blueprint:
name: IKEA Tradfri 2-Key On/Off Light Switch Handler
description: Translates the on/off action of Tradfri 2-key wireless light switch into light turn on/off service calls.
domain: automation
input:
tradfri_switch_click:
name: Tradfri Switch Click Sensor
description: Exposed sensor of the Tradfri Switch.
selector:
entity:
domain: sensor
target_light:
name: Target light
description: The target light to turn on/off with the switch.
selector:
entity:
domain: light
trigger:
platform: state
entity_id: !input tradfri_switch_click
mode: queued
action:
- choose:
- conditions:
- condition: template
# This is necessary because the 2 key switch also returns long press states which we are not interested in
value_template: '{{ trigger.to_state.state == ''on'' or trigger.to_state.state == ''off'' }}'
sequence:
- service: >
{% if trigger.to_state.state == 'on' %}
light.turn_on
{% elif trigger.to_state.state == 'off' %}
light.turn_off
{% endif %}
target:
entity_id: !input target_light
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment