-
-
Save FloppyGit/efaa93c1d63676e30c4b61adb4a861ac to your computer and use it in GitHub Desktop.
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 |
Thank you for this very helpful blueprint! Out of the box it works perfectly. After first test i just change the transition times of brightness_moves to 0.5. So it was nice and smooth for my taste.
Then I adapted the blueprint a little for myself. I added automation GUI options to set up transition time, delay, and forced brightness at light.turn_on when creating the automation. Now it is even more perfect for my ideas. But without your great work as a basis, I would never have gotten to it so quickly. Thanks again!
Any chance you could share your variant? Nice to have options although this one just worked out of the box so very happy.
Any chance you could share your variant? Nice to have options although this one just worked out of the box so very happy.
Yes, sure, but give me some time. Since I'm only on my mobile phone at the moment, I can't insert the code properly.
@alexsaas . Thank you, but without using three back ticks either side of your code block
, it'll be impossible for a laymen like myself to try and re-indent the yaml correctly.
blueprint:
name: Z2M - Tradfri E1743 Switch On Off Dimming Light
description:
"Controls a light with a switch given by ENTITY. \n\n Short 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_action:
name: Tradfri E1743 Switch
description: The switch-action which triggers this automation.
selector:
entity:
filter:
- integration: mqtt
domain:
- sensor
multiple: false
target_light:
name: Target Light
description: the light you want to control.
selector:
target: {}
force_brightness:
name: Force turn on brightness
description: >
Force the brightness to the set level below, when the "on" button on
the remote is pushed and lights turn on.
default: false
selector:
boolean:
brightness:
name: Brightness
description: Brightness of the light(s) when turning on
default: 100
selector:
number:
min: 0
max: 100
mode: slider
step: 1
unit_of_measurement: "%"
helper_transition_dim:
name: Helper - Transition time for dimming up / down
description: Transition time in seconds for dimming up / down. 0 makes visible steps. Greater than 0.1 makes it smoother. (0.0-10.0)
default: 0.5
selector:
number:
min: 0.0
max: 10.0
mode: box
step: 0.5
helper_delay:
name: Helper - Delay between each dimming step
description: How long should be delayed between each step of dimming in milliseconds. 0 makes no delay. (10-2000)
default: 200
selector:
number:
min: 10
max: 2000
mode: box
step: 10
#source_url: https://gist.github.com/FloppyGit/efaa93c1d63676e30c4b61adb4a861ac
alias: Z2M - Tradfri E1743 Switch On Off Dimming Light
description: ""
variables:
force_brightness: !input force_brightness
trigger:
- platform: state
entity_id: !input source_switch_action
id: "on"
to: "on"
- platform: state
entity_id: !input source_switch_action
id: "off"
to: "off"
- platform: state
entity_id: !input source_switch_action
id: brightness_move_up
to: brightness_move_up
- platform: state
entity_id: !input source_switch_action
id: brightness_move_down
to: brightness_move_down
- platform: state
entity_id: !input source_switch_action
id: brightness_stop
to: brightness_stop
condition: []
action:
- variables:
command: "{{ trigger.to_state.state }}"
- choose:
- conditions:
- condition: trigger
id:
- "on"
sequence:
- choose:
- conditions: "{{ force_brightness }}"
sequence:
- service: light.toggle
target: !input target_light
data:
brightness_pct: !input brightness
default:
- 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: !input helper_transition_dim
target: !input target_light
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: !input helper_delay
count: 50
- conditions:
- condition: trigger
id:
- brightness_move_down
sequence:
- repeat:
sequence:
- service: light.turn_on
data:
transition: !input helper_transition_dim
brightness_step_pct: -5
target: !input target_light
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: !input helper_delay
count: 50
mode: restart
Just popped it here for reference too. Hope you don't mind @FloppyGit
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
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
Thank you for this very helpful blueprint! Out of the box it works perfectly. After first test i just change the transition times of brightness_moves to 0.5. So it was nice and smooth for my taste.
Then I adapted the blueprint a little for myself. I added automation GUI options to set up transition time, delay, and forced brightness at light.turn_on when creating the automation. Now it is even more perfect for my ideas. But without your great work as a basis, I would never have gotten to it so quickly. Thanks again!