IKEA Tradfri E1743 Switch to Light via zigbee2mqtt (simple setup)

I have many of this switches and I wanted a simple configuration. So you only setup the Switch as source, and set a Target Light. No further Action needed.

What it does (not configurable!):
Clicking "off or “on” will toggle the light.
Holding “on” will increase brightness.
Holding “off” will decrease brightness.
Brightness is changed by 5% every 0,2s.
Releasing “on” or “off” will stop changing brightness.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Hosted on Github:

3 Likes

Wasn’t there one already??

1 Like

I tested availble blueprint from EPMatt and Kroning for this switch, but none worked like I want. By behavour or bugs.
I think the blueprint from EPMatt has bugs with changing brightness and it was too complicated to setup. I tried to trace it down, but failed. Also I dont want to need to create for each switch a helper text entity for “Last Controller Event”

I wanted a KISS solution :slight_smile: Works for me. And I am willing to share. maybe its helpfull for someone.

1 Like

Thanks for this, very much appreciated. Works a damn treat!

@xbmcnut you asked for it in gist, but I couldn’t paste the code there properly. So try here. Here are my little additions to the already excellent Blueprint:


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


EDIT: Syntax Changes with Core 2024.08 - 2024.10


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. Angepasste Blaupause! Original, siehe source_url"
  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
triggers:
  - trigger: state
    entity_id: !input source_switch_action
    id: "on"
    to: "on"
  - trigger: state
    entity_id: !input source_switch_action
    id: "off"
    to: "off"
  - trigger: state
    entity_id: !input source_switch_action
    id: brightness_move_up
    to: brightness_move_up
  - trigger: state
    entity_id: !input source_switch_action
    id: brightness_move_down
    to: brightness_move_down
  - trigger: state
    entity_id: !input source_switch_action
    id: brightness_stop
    to: brightness_stop
conditions: []
actions:
  - variables:
      command: "{{ trigger.to_state.state }}"
  - choose:
      - conditions:
          - condition: trigger
            id:
              - "on"
        sequence:
          - choose:
              - conditions: "{{ force_brightness }}"
                sequence:
                  - action: light.toggle
                    target: !input target_light
                    data:
                      brightness_pct: !input brightness
            default:
              - action: light.toggle
                data: {}
                target: !input target_light
      - conditions:
          - condition: trigger
            id:
              - "off"
        sequence:
          - action: light.toggle
            data: {}
            target: !input target_light
      - conditions:
          - condition: trigger
            id:
              - brightness_move_up
        sequence:
          - repeat:
              sequence:
                - action: 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:
                - action: 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

2 Likes

Legend. Thank you so much! And that was fast!! :bullettrain_front:

You’re welcome. Good luck.

Hey @alexsaas thanks for your contribution. I’m a newbie on installing Blueprints in HA. I have to copy the whole code and insert it in the old blueprint? Can you please also point me out exactly where I need to insert my Switch details and target light? Kindly appreciate all the help . Best regards

@Johnnycsi I’ll try to explain it in an understandable way.

First of all, if you are using the Home Assistant Core 2024.10, you must use the code added above or adapted because of the new syntax (see EDIT).

  1. You need an editor like File Editor or Studio Code Server to get into the homeassistant directory.
  2. in homeassistant/blueprints/automations/ you should create a directory called custom if it doesn’t already exist…
  3. in this directory homeassistant/blueprints/automations/custom/ create a new file, the name is free. For example: z2m_-_tradfri_e1743_switch_on_off_dimming_light.yaml
  4. Then you can copy the code from above and paste it into the file and save it.
  5. In the Home Assistant UI go to Settings > Automations & Scenes and select Create Automation.
  6. In the following window, you should then be able to select the blueprint as the basis of the new automation and could create the automation. All your entities and options will then be queried there.

Check here for more information:
Using automation blueprints - Home Assistant

1 Like

Thank you so much for the explanation. I learned something new and I did managed to add the automation. Thanks once again for taking the time to explain me. Keep up the great job! :handshake:

1 Like

You’re welcome. I’m happy if I could help.

1 Like

Hi @xbmcnut @Johnnycsi in case you are still using the blueprint, like me.

I wanted to be prepared for the upcoming Zigbee2MQTT 2.0 (Release January 2025) and rebuilt the blueprint. This now uses the MQTT trigger (as recommended) instead of the discontinued Action Sensor.

Of course I would like to share this with you:

blueprint:
  homeassistant:
    min_version: 2024.10.0
  name: Z2M - Tradfri E1743 Switch On Off Dimming Light (MQTT trigger)
  description:
    "Controller automation for actions triggered by IKEA TRADFRI on/off switch E1743 using Zigbee2MQTT.
    Short Button press will toggle light for both Buttons (helpfull in darkness).
    Mode set to restart is mandatory for stop after long press to work. Customized blueprint! Original see source_url"
  domain: automation
  input:
    controller:
      name: (Zigbee2MQTT) Controller Name of the E1743 Switch
      description: The name of the controller as defined in z2m (e.g. Livingroom Switch)
      default: ""
    base_topic:
      name: (Zigbee2MQTT) Base mqtt topic
      description: The base topic as configured in z2m
      default: zigbee2mqtt
    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
  #Contains code snippets from: https://github.com/chris-1243/HA---Blueprint/blob/411a2ce53013b1a357bc1b566ceb2c6e6319b682/PTM_215Z_ZE%20(mqtt_trigger).yaml
variables:
  force_brightness: !input force_brightness
trigger_variables:
  base_topic: !input "base_topic"
  controller: !input "controller"
triggers:
  - trigger: mqtt
    topic: '{{ base_topic ~ "/" ~ controller ~ "/action" }}'
conditions: '{{ "on" | string in trigger.payload or "off" | string in trigger.payload or "brightness_stop" | string in trigger.payload or "brightness_move_" | string in trigger.payload }}'
actions:
- variables:
    action: '{{ trigger.payload }}'
- choose:
    - conditions:
        - condition: template
          value_template: '{{ action == "on" }}'
      sequence:
        - choose:
            - conditions: "{{ force_brightness }}"
              sequence:
                - action: light.toggle
                  target: !input target_light
                  data:
                    brightness_pct: !input brightness
          default:
            - action: light.toggle
              data: {}
              target: !input target_light
    - conditions:
        - condition: template
          value_template: '{{ action == "off" }}'
      sequence:
        - action: light.toggle
          data: {}
          target: !input target_light
    - conditions:
        - condition: template
          value_template: '{{ action == "brightness_move_up" }}'
      sequence:
        - repeat:
            sequence:
              - action: 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: template
          value_template: '{{ action == "brightness_move_down" }}'
      sequence:
        - repeat:
            sequence:
              - action: 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
max_exceeded: silent

That’s very thoughtful of you, thank you. I had tweaked your original BP but I’m unsure what I added. I’ll download your new one and check.

EDIT: Seems I tweaked the transition time default to 0.5 but I see you’ve done that in the new version anyway👍

Great. Thanks for sharing.

Can you use a selector for the device rather than manually entering like the earlier BluePrint?

@yarafie Unfortunately, a selector is not possible. Because Home Assistant doesn’t natively offer a selection of the names you need from zigbee2mqtt.

However, since this name has to be written exactly as in zigbee2mqtt as part of the Topic, it unfortunately has to be entered manually.

Would the below work?

Define UI and default values

input:
remote_device:
name: Remote
description: 'Select IKEA remote

default:
selector:
device:
filter:
- integration: mqtt
manufacturer: IKEA
model: TRADFRI on/off switch (E1743)
multiple: false

No, because no device or entity can be selected here. This blueprint triggers on an MQTT topic. And as part of this topic, the name has to be taken exactly from Zigbee2MQTT and must be entered in the field. That cannot be changed. And there is no selector for that:

Sorry but I think I already explained this in my previous post, didn’t I? It’s really not a big deal to type in the name, is it?
Either you can come to terms with it or you should look for another blueprint.

Maybe (really maybe) in the future, when I think it’s necessary and the event entities are stably supported by Zigbee2MQTT, I’ll rebuild the blueprint again. Then you could select entities again.

Thanks. Still a newbie in HA blueprints, automations etc.

Been reading the HA DOCS a lot but it’s overwhelming.

Thanks for the link I did read it before but now with your explanation it’s making more sense templates vs limited templates .

No offense.

You could rebuild the blueprint so that you can select the MQTT device. But then you would have to completely rebuild all the triggers. That would be doable, but it is time-consuming and I don’t know if it will work.

I’m not a professional either. I‘m a beginner too. :wink:

@yarafie The author has adapted his original blueprint today, maybe it will help you:

1 Like