ZHA - IKEA Tradfri On/Off Switch

These remotes just report “on” press, “on” hold, “off” press, and “off” hold and don’t (natively) have actions on double or triple taps (though you could probably do an automation that counts taps and does timing to kludge this, there are other blueprints here that you can examine to adapt this one to do this)

With the native functionality, you could still control two devices, one would be turned on/off with pressing the appropriate button, and the other turned on/off by holding the appropriate button (that is what I am doing with mine)
Or you could use a toggle action and control 4 devices with these 4 actions…

Brilliant! very clean blueprint… this will have great use! so big thanks @Xelloss99 for sharing :slight_smile: :smiley:

I made a Blueprint that combines this with the on/off/dimming blueprint referenced in this topic. By default, it will turn a specified light on/off and dim it, but any of the four presses (on/off/hold-on/hold-off) can be overridden and customized. I wanted a light control button that mostly behaved like normal, but could use a long-press to turn the light on to full brightness instead of the last value. It can be found here: ZHA - Ikea Tradfri wireless dimmer with options for custom actions

My experience with this blueprint is that when the light has been off for a while and I turned it back on, it turns on on the lowest brightness. Is there a way to fix that?

The blueprint just calls the service you specify. If it is a light.turn_on service, without further options/service data, that will normally turn the light on at the same brightness it was last left at.

Depending on the integration of your light, if your light dims over time, it may be that the integration read back the light status after it started dimming, but before it turned off so it may have recorded that it was at a low brightness the last time it was “on” (my GE Z-Wave dimmers seem to do this).

If you always want an action in the the blueprint to turn the light on to full (or any specific) brightness, just specify that in the options/service data.

Is there a way to find that in the blueprint? I wasn’t able to find it

You are not using the blueprint in this thread. Check in that blueprint’s discussion thread.
But likely there will need to be a change to the blueprint itself to add the brightness:100 data to the turn on command.

I tried using this and got this error:

alias: ZHA - IKEA wireless on/off switchdescription: ''use_blueprint: pat - Pastebin.com is giving me the error “Error: UndefinedError: ‘dict object’ has no attribute ‘event’”

I’m not sure if it’s related to the ikea outlet not being paired correctly (however I’ve re-paired it already to test). I say this because if I manually toggle the outlet on in the configuration of the device, it works, same when I toggle it off, but then it sets itself to “On” when it physically is still off.

EDIT / UPDATE: I came back to this issue the next day, and everything was working fine. It seems the zigbee network just needed time to settle in after being paired.

1 Like

I imported this blueprint but my switch isn’t showing up in the device list. I have it among my devices (it’s connected to the IKEA gateway). I tried connecting it directly to deCONZ through the Phoscon web app, but that doesn’t seem possible.

I’m new to HA but I figured this little switch would be the easiest in the world to get working :-/

This blueprint is made for ZHA and not deCONZ.
You might wanna check out this blueprint (deConz - IKEA Tradfri on/off switch) instead.

Hi
Has anyone lost the function of long press since the latest HA update. 2022.4.1

With the latest update to Home Assistant, the long press feature no longer works.

How can I make it work again with this blueprint?

Hi
See this link ZHA - IKEA five button remote - #39 by sanghviharshit
This helped me out, I edited the yaml for this blueprint and long press works again.

What did you change in the yaml?
I would be grateful if you could post it here. I can’t get it to work.

  • choose:
    • conditions:
      • ‘{{ command == ‘‘on’’ }}’
        sequence: !input ‘button_on_short’
    • conditions:
      • ‘{{ command == ‘‘off’’ }}’
        sequence: !input ‘button_off_short’
    • conditions:
      • ‘{{ command == ‘‘move_with_on_off’’ }}’
        sequence: !input ‘button_on_long’
    • conditions:
      • ‘{{ command == ‘‘move’’ }}’
        sequence: !input ‘button_off_long’

Hi
See the section choose,I deleted the middle sections of each conditions and then restarted HA.

4 Likes

@Eddie46848
Thank you. It is working again.

Here is the whole updated blueprint file.

blueprint:
  name: ZHA - IKEA wireless on/off switch
  description: Control anything using IKEA wireless on/off switch

  domain: automation
  input:
    remote:
      name: Remote
      description: IKEA wireless on/off switch to use
      selector:
        device:
          integration: zha
          manufacturer: IKEA of Sweden
          model: TRADFRI on/off switch
    button_on_short:
      name: On button press
      description: Action to run on press of On button
      default: []
      selector:
        action:
    button_off_short:
      name: Off button press
      description: Action to run on press of Off button
      default: []
      selector:
        action:
    button_on_long:
      name: On button hold
      description: Action to run on long press of On button
      default: []
      selector:
        action:
    button_off_long:
      name: Off button hold
      description: Action to run on long press of Off button
      default: []
      selector:
        action:

mode: restart
max_exceeded: silent

trigger:
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input remote

action:
  - variables:
      command: "{{ trigger.event.data.command }}"
      cluster_id: "{{ trigger.event.data.cluster_id }}"
      endpoint_id: "{{ trigger.event.data.endpoint_id }}"
      args: "{{ trigger.event.data.args }}"
  - choose:
      - conditions:
          - "{{ command == 'on' }}"
        sequence: !input button_on_short

      - conditions:
          - "{{ command == 'off' }}"
        sequence: !input button_off_short

      - conditions:
          - "{{ command == 'move_with_on_off' }}"
        sequence: !input button_on_long

      - conditions:
          - "{{ command == 'move' }}"
        sequence: !input button_off_long

1 Like

Hey guys,

Same issue with the long press,

So how do import a blueprint without the blueprint button LOL?

EDIT

I just created a new file in a subfolder under blueprints and copy paste the YAML there.

Thanks boradwell :slight_smile:

Im using this to control Spotify, and for some reason (no matter what template ive tried) the volume is not a constant up and down :frowning:

Anyone have an idea of why that is?

Thanks - a huge help! These edits also worked with another related blueprint, ZHA - IKEA wireless on/off switch

Hello thank you for this blueprint, it looks very clean. But for some reason I cannot get one use case working. I wanted to turn light on, wait some time and turn it off.

But then I mapped those actions in this blueprint to any button press light never turn off

button_on_short:
      - service: light.turn_on
        target:
          device_id: 36164ac7b7536bc1a0ef04f74af8e534
        data:
          rgb_color:
            - 255
            - 0
            - 0
      - delay:
          hours: 0
          minutes: 0
          seconds: 20
          milliseconds: 0
      - service: light.turn_off
        target:
          device_id: 36164ac7b7536bc1a0ef04f74af8e534
        data: {}

I even tried it with custom script with those 3 actions and cashed from blueprint but with no luck.

I tried to edit your blueprint but I am quite noob in it still.

I got it working with different blueprint (Controller - IKEA E1743 TRÅDFRI On/Off Switch & Dimmer | Awesome HA Blueprints)

But that have different issue (long press not working and not maintained)

If you could help me it would be wonderful.

Thanks