Deconz with IKEA Trådfri

Hi!

Components:
Raspberry PI 2 Model B
RaspBee Zigbee gateway
Deconz
2pcs IKEA Trådfri E1524 Remotes
1pcs IKEA Trådfri ON/OFF switch E1743
Different Trådfri light bulbs

I am new to the whole HA. Bought myself RaspBee, and has been successfully installed Deconz and added my first lights (IKEA Trådfri).

However… I too want to be able to use switches as well, and I am having trouble getting this to work.

When I try to add through the “add switch” wizard, I get stuck on “Press button for 10 seconds”. However, when I add the switches through “other”, they seem to be added correctly.

Now, if I go to a group I have created and add a switch. Nothing happens after I bind a key to it.
Lights working perfect if I manually click the lightbulb Icon or if I add a switch in HA frontend. But the remotes does not work.

I have tried to reinstall Deconz. Restarted HA many times, also tried to create an Automation in HA with the remote, still same issue.
Updating the firmware does not work, just show the same version after reboot…
Phoscon GW Version 2.05.72 / 12.12.2019
Rasbee firmware: 26050500

Any tip?

That’s fine. As long as the remotes have been recognised in Deconz.

The Home Assistant way is to write an automations. I’ve not used Deconz beyond initial adding stuff to my zigbee mesh. Everything is done in Home Assistant Automations.

Here is code to use the Ikea 5-way remote centre button as toggle switch for lights:

- alias: Input - Ikea 5-way-switch middle button
  id: '1573509777394'
  description: ''
  trigger:
  - event_data:
      id: tradfri_remote_control
      event: 1002
    event_type: deconz_event
    platform: event
  condition: []
  action:
  - data_template:
      entity_id:
      - light.master_bedroom_lights
      - light.bedroom_2_light_bulb
      transition: 1
      brightness: '{% if (states.light.all_bedroom_lights.state == "on") %} 0  {%
        else %} 255 {% endif %}'
    service: light.turn_on

Here’s more advanced example to use the up/down button as mode-select. The remote is at top of my stairs, the stair lights are automatic motion sensed, we mainly the remote to turn on or off all bedroom lamps as desired, and switch between pre-set modes that don’t happen at predefined times (eg. from evening to nighttime, from nighttime to morning)

- alias: Input - Ikea 5-way-switch dimmer up-down
  id: '1573509777395'
  description: ''
  trigger:
  - event_data:
      id: tradfri_remote_control
    event_type: deconz_event
    platform: event
  condition:
    condition: template
    value_template: '{{ trigger.event.data.event in [3002, 3001, 2002, 2001] }}'
  action:
  - entity_id: input_select.upstair_lights_mode
    service_template: '{% if (trigger.event.data.event in [3002, 3001]) and (not is_state("input_select.upstair_lights_mode",
      "nighttime")) %} input_select.select_next  {% elif (trigger.event.data.event
      in [2002, 2001]) and (not is_state("input_select.upstair_lights_mode", "daytime"))
      %} input_select.select_previous {% endif %}'
  - service: script.light_turn_on_stair

Thanks a lot for the reply! I will try this when I get home.
To add another stupid question.

How do I write an automation?
Under Configuration -> Automation I get a site to add Trigger, Condition and Action.
But it does not seem like a place to add code?

You have found the right place. You see in the code there’s corrisponding trigger, condition and action sections.
For trigger, select event and type select deconz_event. Paste the data into the data box. Similar things for Action.

Alternatively, in your Home Assistant configuration directory, there should be a file “automations.yaml”. You can paste the code into there. Reload automations via “Settings -> Server Controls” screen and you’ll see this automation in your HA.

Thanks! This gets me longer. I did use your code, and if I go to Automations and manually triggers it; the light goes on. But I think there still is a problem with my remotes.

Is it correct that I only find “Battery level” as an entity? Or should it have more entities?

That is correct. Remotes do not have entities because it doesn’t have a state, they only have events. So your trigger need to look at the events. See: https://www.home-assistant.io/integrations/deconz/#remote-control-devices

On that page, there’s also better examples.

Ah, that makes sense.
Thanks for your patience! You are being of much help.

Anyways, this only got me a little further. I will show you my automation and deconz log.
I tried to subscribe to “Listen to Event” deconz_event. And clicked on different buttons, but could not see any event in the log.

log config:

logger:
  default: critical
  logs:
    # log level for HA core
    homeassistant.core: fatal
    # log deconzzzzzz
    pydeconz: debug
    homeassistant.components.deconz: debug

Automations:


#TEST 1
- id: '1573509777395'
  alias: Input - Ikea 5-way-switch middle button2
  description: ''
  trigger:
  - event_data:
      event: 1002
      id: tradfri_remote_control
    event_type: deconz_event
    platform: event
  condition: []
  action:
  - device_id: daced0154bb44d4b85b63273f94d14b9
    domain: switch
    entity_id: switch.on_off_plug_in_unit_5
    type: toggle
#TEST 2
- id: '1573509777392'
  alias: Input - Ikea 5-way-switch middle button2
  description: ''
  trigger:
  - event_data:
      event: 1002
      id: tradfri_remote_control
    event_type: deconz_event
    platform: event
  condition: []
  action:
  - data_template:
      entity_id: switch.on_off_plug_in_unit_5
      transition: 1
      brightness: '{% if (states.light.all_bedroom_lights.state == "on") %} 0  {%
        else %} 255 {% endif %}'
    service: light.turn_on

Log:

2020-01-27 22:17:02 DEBUG (MainThread) [pydeconz.deconzdevice] On/Off plug-in unit 5 created as 
{'etag': '5325415026c80a3413f4a2055614a944',
 'hascolor': False,
 'manufacturername': 'IKEA of Sweden',
 'modelid': 'TRADFRI control outlet',
 'name': 'On/Off plug-in unit 5',
 'state': {'alert': 'none', 'on': True, 'reachable': True},
 'swversion': '2.0.019',
 'type': 'On/Off plug-in unit',
 'uniqueid': '00:0d:6f:ff:fe:9a:9e:cb-01'}
2020-01-27 22:17:02 DEBUG (MainThread) [pydeconz.deconzdevice] TRÅDFRI on/off switch created as 
{'config': {'alert': 'none',
            'battery': None,
            'group': '2',
            'on': True,
            'reachable': True},
 'ep': 1,
 'etag': '52a41bde5c7d8ea5d0e5698ce1edd691',
 'manufacturername': 'IKEA of Sweden',
 'mode': 1,
 'modelid': 'TRADFRI on/off switch',
 'name': 'TRÅDFRI on/off switch',
 'state': {'buttonevent': None, 'lastupdated': 'none'},
 'swversion': '2.0.019',
 'type': 'ZHASwitch',
 'uniqueid': '00:0d:6f:ff:fe:bb:39:2f-01-1000'}
2020-01-27 22:17:02 DEBUG (MainThread) [pydeconz.deconzdevice] TRÅDFRI remote control created as 
{'config': {'alert': 'none',
            'battery': 74,
            'group': None,
            'on': True,
            'reachable': True},
 'ep': 1,
 'etag': '8924bd9e3640eb7b6f5704f8e20a8081',
 'manufacturername': 'IKEA of Sweden',
 'mode': 3,
 'modelid': 'TRADFRI remote control',
 'name': 'TRÅDFRI remote control',
 'state': {'buttonevent': None, 'lastupdated': 'none'},
 'swversion': '1.2.223',
 'type': 'ZHASwitch',
 'uniqueid': '90:fd:9f:ff:fe:82:90:3d-01-1000'}
2020-01-27 22:17:02 DEBUG (MainThread) [pydeconz.deconzdevice] TRÅDFRI remote control (2) created as 
{'config': {'alert': 'none', 'battery': 47, 'on': True, 'reachable': True},
 'ep': 1,
 'etag': 'f6787e6fbd8419abe6ecc824b613a698',
 'manufacturername': 'IKEA of Sweden',
 'mode': 3,
 'modelid': 'TRADFRI remote control',
 'name': 'TRÅDFRI remote control (2)',
 'state': {'buttonevent': None, 'lastupdated': 'none'},
 'swversion': '1.2.214',
 'type': 'ZHASwitch',
 'uniqueid': '90:fd:9f:ff:fe:de:8a:7d-01-1000'}
2020-01-27 22:17:02 DEBUG (MainThread) [pydeconz.websocket] Websocket starting
2020-01-27 22:17:03 DEBUG (MainThread) [homeassistant.components.deconz] deCONZ event created: tradfri_on_off_switch
2020-01-27 22:17:03 DEBUG (MainThread) [homeassistant.components.deconz] deCONZ event created: tradfri_remote_control
2020-01-27 22:17:03 DEBUG (MainThread) [homeassistant.components.deconz] deCONZ event created: tradfri_remote_control_2
2020-01-27 22:17:04 DEBUG (MainThread) [pydeconz.websocket] Websocket running
2020-01-27 22:17:18 DEBUG (MainThread) [pydeconz.websocket] Websocket starting
2020-01-27 22:17:18 DEBUG (MainThread) [pydeconz.websocket] Reconnecting to deCONZ in 15.
2020-01-27 22:17:33 DEBUG (MainThread) [pydeconz.websocket] Websocket starting
2020-01-27 22:17:33 DEBUG (MainThread) [pydeconz.websocket] Websocket running
2020-01-27 22:21:14 DEBUG (MainThread) [pydeconz.websocket] {"config":{"alert":"none","battery":34,"on":true,"reachable":true},"e":"changed","id":"4","r":"sensors","t":"event","uniqueid":"90:fd:9f:ff:fe:de:8a:7d-01-1000"}
2020-01-27 22:23:35 DEBUG (MainThread) [pydeconz.websocket] {"config":{"alert":"none","battery":21,"on":true,"reachable":true},"e":"changed","id":"3","r":"sensors","t":"event","uniqueid":"90:fd:9f:ff:fe:82:90:3d-01-1000"}

I’m not familiar with the way you are debugging, I’m not sure what to make of the log, sorry. I’ve only just started using HA a few months ago. But try use info instead of critical for logger default, I find it displays more information, including automation trigger and condition test results.

The way I debug button presses is in Developer Tools -> Events page, I type “deconz_event” into listen box and click “start listening”. Then every button press generates an event, event information appears under the Listen to Event box.


Let's break down the automations:

Your automation trigger looks good. No condition. So if you press the middle button on the remote, then go back to HA, press the circled i in Settings -> Automation screen, you should see the automation had been triggered a few seconds ago. That would suggest the remote and automation triggers are working correctly.

Now let’s look at actions. I’m not familiar with your Test 1 action… I’ve never done it this way… For Test 2, my example I posted was too complicated, it contained templates.

Try something like this. Ensure the ID for remote and light are 100% correct. Find the correct event_data by listening to events.

- id: '1573509777392'
  alias: Input - Ikea 5-way-switch middle button2
  description: ''
  trigger:
  - event_data:
      event: 1002
      id: tradfri_remote_control_2
    event_type: deconz_event
    platform: event
  condition: []
  action:
    service: light.toggle
    entity_id: light.lamp

Hi, bought myself a Philips Hue dimmer switch today. It took me 2minutes to get it all working with my automations… Now it also made a lot of sense the whole “Listen to events”, because now actually lines appear under it!
So I believe that the problem was with the IKEA switches all along. Still annoying, since I have 3 switches just laying around! I am able to add them every time, but they give no events what so ever…!
Could it be because I am running Rasp Pi 2b?

RPi 2 is slower but should still work. Puzzling all of your Ikea switches doesn’t work.

Apart from occasional connection issues after reboot, my Ikea original rotary dimmer (no longer on sale), 5 way switch and on/off switch all works well. Only difference is I’ve got a Conbee 2 stick rather than the hat transceiver.

Only thing I can think of is, though you’ve probably already tried, is pair and button presses next to the Pi to eliminate issue caused by weak signal?

I still struggle with this.
Bought 2 IKEA tradfri sensors yesterday, but same issue as with the switches.
Do not change state, or show any signs of movement.

Thinking about buying a new PI 4 tomorrow, but I have a feeling it won´t solve my problem.
I´d really like to hear if anyone else got raspbee and IKEA Trådfri remotes/sensors to work. Or if Raspbee has an error with this…
My friend as well, testet my remotes with Conbee, working like a charm… annoying!

As I have told earlier, anything from Hue is working perfectly in my setup, and also if I use IKEA gateway my remotes work.

Hi again!

Finally got it working, ish…
I purchased a new pi 4, did a backup of the old Home Assistant and set it up again on the pi 4. But it still didn’t work… But then I reset the gateway in deconz GUI, and voila I got my first IKEA switch working.

However, after I got that working and lost all my lights setup, I can’t get 2 out of 3 HUE Dimmer switches to work (they worked before) and still no game with the IKEA motion sensors…

All in all the RaspBee seem to be very unstable.

Everything is solved…
Firmware upgrade of the RaspBee did everything.
Had to set up my old pi 2 with raspbian, took me couple of hours to google all the prerequisites needed to update it…

At last! :smiley: