Skip to content

Instantly share code, notes, and snippets.

@FloppyGit
Last active February 14, 2025 16:02
Show Gist options
  • Save FloppyGit/efaa93c1d63676e30c4b61adb4a861ac to your computer and use it in GitHub Desktop.
Save FloppyGit/efaa93c1d63676e30c4b61adb4a861ac to your computer and use it in GitHub Desktop.
Home Assistant Automation Blueprint: Tradfri E1743 Switch to Light via zigbee2mqtt
blueprint:
name: Tradfri E1743 Switch to Light via zigbee2mqtt
description: "Updated to Z2M v2. Controls a light with a given TRADFRI on/off switch. \n\nShort Button press will toggle light for both Buttons (helpfull in darkness) \n\n Mode set to restart is mandatory for stop after long press to work."
domain: automation
input:
source_switch_e1743_action:
name: Tradfri E1743 Switch
description: The switch-action which triggers this automation.
selector:
device:
entity:
integration: mqtt
filter:
manufacturer: IKEA
model: TRADFRI on/off switch
target_light:
name: Target Light
description: the light you want to control.
selector:
target:
alias: Tradfri E1743 Switch to Light via z2m-v2
description: ""
trigger:
- domain: mqtt
trigger: device
device_id: !input source_switch_e1743_action
type: action
subtype: "on"
id: "on"
- domain: mqtt
trigger: device
device_id: !input source_switch_e1743_action
type: action
subtype: "off"
id: "off"
- domain: mqtt
trigger: device
device_id: !input source_switch_e1743_action
type: action
subtype: "brightness_move_up"
id: "brightness_move_up"
- domain: mqtt
trigger: device
device_id: !input source_switch_e1743_action
type: action
subtype: "brightness_move_down"
id: "brightness_move_down"
- domain: mqtt
trigger: device
device_id: !input source_switch_e1743_action
type: action
subtype: "brightness_stop"
id: "brightness_stop"
condition: []
action:
- choose:
- conditions:
- condition: trigger
id:
- "on"
sequence:
- service: light.toggle
data: {}
target: !input target_light
- conditions:
- condition: trigger
id:
- "off"
sequence:
- service: light.toggle
data: {}
target: !input target_light
- conditions:
- condition: trigger
id:
- brightness_move_up
sequence:
- repeat:
sequence:
- service: light.turn_on
data:
brightness_step_pct: 5
transition: 0.2
target: !input target_light
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 200
count: 50
- conditions:
- condition: trigger
id:
- brightness_move_down
sequence:
- repeat:
sequence:
- service: light.turn_on
data:
transition: 0.2
brightness_step_pct: -5
target: !input target_light
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 200
count: 50
mode: restart
@FredrikM97
Copy link

Thank you for the contribution! I also did some modifications to support E2001/E2002 with left and right color changes.
https://gist.github.com/FredrikM97/12d2a59038e24b3135aea5691d802bac

@FloppyGit
Copy link
Author

FloppyGit commented Jan 6, 2025

I've updated this gist as zigbee2mqtt had released v2.0 with some breaking changes. So the input selector and the triggers have been changed. And after updating you have to repair your automation and reselect the device.
see
https://github.com/Koenkk/zigbee2mqtt/releases/tag/2.0.0
https://www.zigbee2mqtt.io/guide/usage/integrations/home_assistant.html#via-mqtt-device-trigger-recommended

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment