Skip to content

Instantly share code, notes, and snippets.

@HarvsG
Last active October 30, 2024 22:54
Show Gist options
  • Save HarvsG/d43344cbe07e046cdda50c2458018c33 to your computer and use it in GitHub Desktop.
Save HarvsG/d43344cbe07e046cdda50c2458018c33 to your computer and use it in GitHub Desktop.
Adding IKEA Tradfri Devices with ZHA on Home Assistant

Shortcut and On/Off switches

  1. Remove back cover with philips scredriver and instert provided battery
  2. In home assistant select a ZHA always-on zigbee device - such as a powered light or signal repeater in the same room the shortcut button will end up in
  3. Select "Add device via this device"
  4. Press the pair button 4 times on the back of the shortcut button
  5. Wait
  6. If using an On/Off switch and you want to bind it to a bulb for non-controller dependant control (i.e will work if home assistant is down)

Pairing On/Off Switches to IKEA Bulbs

For firmware versions 2.3.0.75 or greater.

Before version 2.3.075 The IKEA on/off switches only bind to zigbee groups After they only bind to individual devices: The most reliable method seems to be: In ZHA for me that process is bring up the device page for the switch, 3 dots the the right of the reconfigure button, manage ZigBee device, bindings.

  1. Consider updating to the latest firmware, as updates alter this functionality.
  2. Unbind the switch from all devices including the co-ordinator
  3. Unbind from all groups (check all clusters) <-- not sure if necessary
  4. Reconfigure the device from the ZHA UI <-- not sure if necessary.
  5. Unbind from the coordinator again <-- not sure if necessary
  6. Bind with the desired lights
  7. Re-bind with the coordinator (This ensures the homeassistant UI acutally shows the state changes)
  8. If the lights do not update their status in the UI when turned on or off by the switch, then click RECONFIGURE DEVICE for each light, making sure to refresh the page between each device

Note about shortcut buttons

At software version number 2.3.015 they have 3 possible comands "on" (triggered with a short press) "move_with_on_off" triggered by a long press and "stop" triggered by a release of a long press. Each message may also be duplicated many times (apparently this is within the zigbee spec, but you may have to control for it in node-red (this node is helpful)

Somewhere between 2.3.015 and 2.3.80 the gain the "off" function which is tiggered by a double click. The message duplication is also improved ?completeley resolved?

Checking software version numbers in ZHA

  1. Device page of the device in question
  2. Manage Clusters
  3. "Basic (Endpoint id: 1, Id: 0x0000, Type: in)"
  4. Cluster Attributes -> "sw_build_id (id: 0x4000)"
  5. Click "Get Zigbee Attribute"
  6. If device is battery powered, trigger it somehow
  7. The version should appear in the "Value" box

Updating software in ZHA

I think updating software is generally a good idea, but IKEA often changes functionality with little warning and so it may break some of you systems. ZHA way of managing updates (if enables) is to silently update your devices in the background. Which may mean that things can silently break.

Updating On/Off remotes and shortcut buttons

This post on reddit by u/Wwalltt is currently a good overview of how updates work in ZHA

Version info is as follows from the IKEA server (no changelog): http://fw.ota.homesmart.ikea.net/feed/version_info.json

Tradfri changelog https://ww8.ikea.com/ikeahomesmart/releasenotes/releasenotes.html

Or official docs are a little better than they were: https://www.home-assistant.io/integrations/zha/#ota-firmware-updates

  • As of 2.3.075 or later on switches they go from being able to bind groups and not devices to the opposite
  • For the shortcut buttons as of 2.3.0.75, they gain the off command on double press and the duplicaiton problem is fixed.

In ZHA:

  1. Ensure you have OTA updates enabled in ZHA (see above)
  2. In my experience devices begin updating soon after joining the network anyway - you can skip to step 8/9 to check
  3. Select the device you want to update
  4. Select Manage Clusters
  5. Select Ota (Endpoint id: 1, Id: 0x0019, Type: out)
  6. In the Cluster Commands drop-down, (not Cluster Attributes) select image_notify (id: 0x0000)
  7. Click ISSUE ZIGBEE COMMAND whilst waking the device
  8. Wait One device took approx 2 hours(!)
    • there is no obvious way to tell if the update has started except to SSH into the HA and run tail -f home-assistant.log | egrep zigpy which should show an increasing upgrade percentage if you have DEBUG level logging for zigpy/ZHA.
  9. You can track the progress with tail -f home-assistant.log | egrep "OTA upgrade progress:"
@Alveoli
Copy link

Alveoli commented Sep 29, 2023

Very informative posts, thank you.

I just bought a Tradfri Shortcut button Type E1812 two days and had similar issue - it binds to ZHA, I can see the battery level but no events. I wasn't able to connect to get the sw_build_id (same red exclamation mark error above).

Frustrated, I left it for two days... and this morning it's just started eventing! I did nothing. Didn't check or update the firmware.

Hopefully it continues to work.

@dotkrnl
Copy link

dotkrnl commented Sep 2, 2024

I got three trays of clearance TRADFRI Shortcut Buttons yesterday and was frustrated as they only reported battery status but no events at all, lol. I found a few comments stating that the SkyConnect doesn't work with it, so I was worried I had just bought three trays of bricks. Fortunately, after trying for 5+ hours, I figured out a reasonable flow to make them work with ZHA.

  1. To get a clean start, reboot your HA box. Somehow I got into an unstable state where, despite a lot of effort, I couldn't proceed with the following steps.
  2. Add the TRADFRI Shortcut Button using a Zigbee router by opening a wired Zigbee device, such as a light bulb, in HA, selecting Add devices via this device. I'm not sure if this is needed for coordinators other than SkyConnect, but I was unable to get it to work without a router.
  3. Press the "Pair" button on the back of the TRADFRI Shortcut Button six times quickly; no need to keep pressing. Wait until the device is interviewed and configured. If it gets stuck for a long time, reboot the HA box, remove the added device, and repeat from Step 2. Proceed to step 4 when you get the configured device added to HA.
  4. Try pushing the button and see if you get a ZHA event. If not, repeat this step until you do: While pressing the button every second to keep it awake, click Reconfigure for the shortcut button on HA and start reconfiguring. Show all details and wait until it shows configuration done and all ticks are green. If not, repeat this step. If it gets stuck, press the "Pair" button six times quickly and reconfigure again. Try to see if you have a ZHA event now; if not, repeat.
  5. Now you have a stable connection with the button! If you're satisfied with this, you're done. If you'd like to upgrade, follow the next steps.
  6. As of today, OTA for IKEA devices in Zigpy has been disabled by default. Enable it following https://github.com/zigpy/zigpy/wiki/OTA-Configuration. You may need to wait for the firmware update to appear in HA.
  7. Open the Firmware update dialog on HA in the device. While pressing the button intermittently to keep it awake, start the upgrade. Keep pressing the button until the upgrade actually starts and the percentage value is shown.
  8. Wait about two hours for the upgrade to complete. For me, it works automatically, but some comments mentioned that clicking the button every few minutes to keep it awake helps.
  9. Once the upgrade is done, remove the battery from the button and reinstall it. You should now be all set. FYI, I use HA Automation to listen to the On ZHA event of the button.

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