How to make an Arlec Smart Ceiling Fan DCF4002WHA work with Hubitat

Tuya is terrible. Hubitat and Home Assistant is not. At the beginning of this project, I only had Hubitat. I tried to get the fan working with Tuya Cloud integration and the ESPHome driver for Hubitat, but both are half-finished and don’t support combined devices like this very well.

So, this how-to will talk you through building a Home Assistant (HA) machine, installing ESPHome, flashing the chip in the fan, configuring it in HA and then synchronising HA to Hubitat.

In addition to the fan itself you will need:

Install Home Assistant
I installed the x86 version on an old Dell mini PC with these instructions - Generic x86-64 - Home Assistant

Install ESPHome
I followed these instructions - Getting Started with ESPHome and Home Assistant — ESPHome

Make some firmware

  1. In the ESPHome tab click New Device in the bottom right.

  1. Rather than installing directly from the computer running HA we will build firmware and install it using a Windows PC. Click Continue.

  1. Name your device
  2. On the Device Type screen select RTL87xx, then Generic – RTL8710BN (2M/788k)

  1. You don’t need the encryption key yet, so no need to take a copy, its just FYI. Click Install.
  2. We want to install it on another computer (not the one running HA), so select Manual Download.

  1. ESPhome will build the firmware and then offer you the file to save.

  1. Choose UF2 Package

You now have a firmware image to flash into your device.
Flash the firmware image

  1. Wire up the board to the UART and Power Supply as below:

This diagram came from projects:arlec_smart_fans:overview [Travis' Wiki] however it had a typo, which I have corrected in red.

  1. Open the fan controller module. Remove the WR4 PCB from the main board and remove the block of foam from the pins. Be careful to not jerk the Wi-Fi antenna cable as the unit comes apart.

The unit is full of 240V when its live, and possibly it will still be charged with high voltage DC for several minutes after power is removed. Be careful.

  1. Solder ~10cm lengths of wire-wrap wire to the respective pins of the PCB. A magnifying workstation helps a lot here, particularly if your eyes are old like mine.

  1. Solder pins onto the other end of the wire-wrap wire to push into the breadboard.
  2. Assemble the build per the circuit diagram. Make sure the Wi-fi antenna is connected.

  1. Download ltchiptool from Releases · libretiny-eu/ltchiptool · GitHub into a working folder. Copy the firmware image from above into the same folder.
  2. Open ltchiptool and go to the terminal tab. Set the baud rate to 115200 and click Open Port. Power on the power supply and you should see the boot loader waiting for instructions:

If not check your connections and try again.

  1. Click on the Flashing tab, pick Realtek AmebaZ and, Get chip info and click Start, you should get some info from the chip.

  1. Backup the firmware by selecting Read flash and clicking Start. You should get a 2mb .bin file saved in the working folder with the Tuya firmware in it.
  2. Write the firmware you saved in the last section to the chip by selecting Write flash and clicking Start.

Once the firmware is written you’ll see it boot up in the Terminal tab:

Customise the firmware to talk to the Arlec Fan
Currently your WR4 module is talking to ESPHome as shown by it being ONLINE:

Now we can customise the ESPHome configuration so it talks to the MCU (controller) of the fan and light.

  1. Click the EDIT button and append the following configuration to the configuration YAML file:
uart:
  rx_pin: GPIO18
  tx_pin: GPIO23
  baud_rate: 9600  # This is a common baud rate for Tuya devices

# Configure the Tuya component and ignore the datapoints not used in this configuration (e.g. sleep timer)
tuya:
  ignore_mcu_update_on_datapoints:
    - 102
    - 103

# Fan configuration
fan:
  - platform: tuya
    name: "Ceiling Fan"
    id: ceiling_fan
    switch_datapoint: 1
    speed_datapoint: 3
    direction_datapoint: 4
    speed_count: 6

# Light configuration
light:
  - platform: tuya
    name: "Light"
    id: ceiling_fan_light
    switch_datapoint: 9
    dimmer_datapoint: 10
    min_value: 0
    max_value: 100
    color_temperature_datapoint: 11
    color_temperature_max_value: 100
    color_temperature_invert: false
    cold_white_color_temperature: 6493 K
    warm_white_color_temperature: 4065 K
    default_transition_length: 0s
  1. Click SAVE then INSTALL. We can now install updates Over the Air (OTA) so click Wirelessly:

  1. ESPHome will compile and push the new firmware to the device over wifi and reboot it. The device will now hang however as we still have the RXD and DTR lines on the UART linked which boots the chip into the bootloader.
  2. Remove RDX-DTR the link and power cycle the WR4.
  3. You’ll see the WR4 boot back up in both the ltchiptool terminal and ESPhome. It will connect to wi-fi and then repeat errors communicating with the Tuya MCU as its not connected.

  1. Click STOP and close the configuration window in ESPHome.
  2. You can now unsolder the wire-wrap wires and re-assemble the WR4 PCB back into the fan controller. Note that the MCU socket closest to the antenna should be empty as there isn’t a matching pin on the WR4 PCB.
  3. Put the casing back together, being careful to keep the wi-fi antenna connected and not tangled up inside the case. Re-attach the wiring harness to the module and install the fan as per the instructions.
  4. When you power up the assembled fan you should see any button presses on the remote come through in the log as the fan changes speed, etc.

Configure the fan device in Home Assistant

  1. Make sure the fan is powered up and connected to Wi-fi. You should see it connected and logging to ESPHome.
  2. In Home Assistant click Settings, Devices & services:

  1. Scoll down to ESPhome and click the arrow:

  1. Click ADD DEVICE and pick the new device from the list. Confirm you’s like ESPHome to add the device to HA. Click SUBMIT.
  2. Confirm which area you’d like the device in and click FINISH.

  1. You should now see a live connection between the fan and light, and the virtual child devices in HA.

Sync the HA device to Hubitat

  1. Instal Home Assistant Device Bridge (HADB) into Hubitat. I recommend using Hubitat Package Manager to do so. Details here - [RELEASE] Home Assistant Device Bridge (HADB)
  2. Once HADB is configured you can pick the fan and light devices in the app:

  1. One important trick is that the HA devices won’t be installed as children of the HADB device until you make them do something in HA. So go into the HA GUI and toggle the fan and light switch on and off.

All feedback welcome!

9 Likes

Well done ... thats a lot of work! I am glad it all works for you now. :grinning:

2 Likes