As of 9/13/2024:
Posting to share my success in connecting Ikea Tradfri to Home Assistant with just a Sonoff ZBDongle-P.
NOTE: Be careful flashing firmware, this is for the Sonoff ZBDongle-P model ONLY
I have Home Assistant running on a PI 4 connected to my router by ethernet cable. I have the Sonoff ZBDongle connected to it with a usb extender (link1). I was able to pair the Tradfri bulb by keeping the light off for about 1-2 seconds and turning it off just after the light flashes on during the 6 power cycles needed to enter pairing mode, basically just keeping it turned off longer than you do turned on during the power cycling.
When I first paired an Ikea Tradfri light bulb to the Sonoff ZBDongle I was able to control it from the Home Assistant app for about 5 seconds after which it stopped responding. Deleting and readding the bulb did not fix this issue. I noticed the Firmware appeared to be out of date (Z-Stack 20210708) and have seen posts here mentioning the older Sonoff ZBDongles shipped with firmware issues. Previous posts referenced this YouTube video (link2) for flashing new firmware onto the Sonoff device, but I ran into issues with the method that involves taking the case of the Sonoff off and holding the boot button, and the Python script method had a broken link.
Successful Method of Flashing Firmware:
In this post (link3) belastingvormulier linked a GitHub repository where running the “setup.sh” script on Ubuntu was successful in updating the firmware to Z-Stack 20240710. setup.sh requires you have cc2538-bsl.py installed from (link4). The setup.sh script downloads firmware from (link5) and runs cc2538-bsl.py to update the firmware.
A few things to make sure of:
- Identify the serial port that is the Sonoff device when plugged in, for me this was /dev/ttyUSB0
- I got this working with Python 3.8.10, pip 20.0.2, and Ubuntu 20.04.6 LTS
- Based on script outputs/errors you will probably have to install additional Python packages (pyserial, intelhex, etc)
- I had to edit the setup.sh where it runs cc2538-bsl.py to allow me to have cc2538-bsl.py in the same folder as setup.sh and work (as of 9/14/2024 this was on line 96 of setup.sh):
sudo python3 cc2538-bsl.py -p ${SERIAL} -e -v -w --bootloader-sonoff-usb CC1352P2_CC2652P_launchpad_coordinator_${FIRMWARE}.hex
- cc2538-bsl.py ran into issues saying I didn’t have intelhex installed when I did. This looked like some path issue so I just moved setup.sh and cc2538-bsl.py to the folder where python packages were installed, for me this was “/home/ubuntu/.local/lib/python3.8/site-packages”
- The last error I got was with cc2538-bsl.py, something about an int, which I eventually traced to the “parse_ieee_address”, which gets called on line 1225:
ieee_addr = parse_ieee_address(args.ieee_address)
When I printed “args.ieee_address” it was “None”, I just replaced args.ieee_address with the specific IEEE address the script had output when I ran it previously (even though the script failed to complete) rather than the variable “args.ieee_address”.
Success!
Once the script completes with out errors, I plugged the Sonoff ZBDongle-P back into my Home Assistant, noting that the firmware was now Z-Stack 20240710. After pairing an Ikea Tradfri bulb I kept the ability to control it!
As a final note, I’ve gotten the best results controlling the Ikea Tradfri bulbs by creating and running a script rather than through the Configuration section of the device. Below is an example:
alias: Edit Ikea Light
sequence:
- action: light.turn_off
target:
device_id:
- [FILL IN YOUR OWN device_id]
data: {}
- action: light.turn_on
target:
device_id:
- [FILL IN YOUR OWN device_id]
data:
brightness_pct: 100
kelvin: 6500
description: Configure Ikea Tradfri Lights
icon: mdi:alarm-light-outline
Hope this helps someone!