Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative firmware #7

Open
hapklaar opened this issue Dec 1, 2021 · 119 comments
Open

Alternative firmware #7

hapklaar opened this issue Dec 1, 2021 · 119 comments

Comments

@hapklaar
Copy link

hapklaar commented Dec 1, 2021

Do you think it would be possible to flash an alternate (open source) firmware on this device, for example Tasmota? This device looks rather similar, but haven't opened my wifi box to see if the innards are the same.

@dennismaxjung
Copy link

dennismaxjung commented Jun 21, 2022

I've replaced the onboard wifi module from Tuya (WBR3) with an ESP12-F

It is fully pin compatible. I flashed ESPHome onto it before i do the soldering.

I also desoldered the 433Mhz RF receiver from the main circuit board and soldered it back directly to the ESP12-F.

Now i can fully control the ceiling fan with Home Assistent and i can also use the remote and every action is visible within HA

PXL_20220619_133516299.MP~2.jpg
ESP12-F Front

PXL_20220619_133509727.MP~2.jpg
ESP12-F Back

PXL_20220619_133501872.MP~2.jpg
Tuya WBR3 Front

PXL_20220619_133453373~2.jpg
Tuya WBR3 Back

PXL_20220619_133445430~2.jpg
Base circuit board with step down voltage regulator on the back

PXL_20220619_133435153~2.jpg
All three boards (backside)

@nielsvanbaal
Copy link

That sounds really nice. Any chance you could make a step by step guide for this? I know my way around soldering but have no exp with esp yet.

@dennismaxjung
Copy link

@nielsvanbaal I had this in mind and i'm currently writing a guide. But I forgot to shoot pictures from the soldering process. But i have another fan module i will working in near future and will make some there.

I'm also fine tuning the ESPHome yaml. It might be needed to do some custom work for each remote to config the right RF Codes.

Also some changes to the ESPHome Tuya Module Code are needed. I've forked some other users code, but want to try to modify and distribute it back to the ESPHome project. So everyone could use it.

@dennismaxjung
Copy link

dennismaxjung commented Jun 23, 2022

Some more pictures:

PXL_20220623_072952413.jpg

PXL_20220623_073021200.jpg

PXL_20220623_073118311.jpg

PXL_20220623_073125701.jpg

@fbloemhof
Copy link

fbloemhof commented Jun 28, 2022

20220628_164022

20220628_164027

Just received my second fan but the controller is different... The board has a new layout. I think it isn't possible to do the same thing with this board.

[edit] Hm the difference might be that I ordered the version without the light?

@dennismaxjung
Copy link

dennismaxjung commented Jun 28, 2022

It would be interesting to see whats on the bottom of the daughterboard. Your version is still Wifi capable?

[edit]: hm the case looks also different

@fbloemhof
Copy link

It is indeed wifi capable, I just added it to the smart life app. It has some improvements, the beep is gone and the actions on the remote are (almost instantly) visible in the app.

The daughter board seems glued of soldered, couldn't get it apart from each other without damaging...

The case is indeed also a little different, it has no screws anymore.

I think I'll mount the fan with this board for now and will look further into it after the summer.

@dennismaxjung
Copy link

dennismaxjung commented Jun 28, 2022

@fbloemhof Where did you buy your fan?

@fbloemhof
Copy link

@dennismaxjung bol.com, sold by Create via their platform.

@DanielWe2
Copy link

@dennismaxjung
Any update on documentation, esphome config or esphome code changes?

@dennismaxjung
Copy link

@DanielWe2 I'm on vacation right now. I will share progress when I'm back

@hspjanssen
Copy link

Interesting, just bought a Create Windcalm DC, looking how to integrate into current Domotica.

@velzend
Copy link
Owner

velzend commented Nov 3, 2022

The replacement of the board is pretty neat. Thanks for sharing!

Good to hear the beep is removed from the new updated fan controller.

I have a couple questions:

  1. Are the states and/ or actions performed using the RF remote control are actually measurable via the GPIOs on the ESP12 board (applicable for the older/ previous fan controler)?

  2. Can you confirm that the new updated fan controler actually updates the (local) Tuya states if the RF remote control is used?

  3. Did they fix the random color temperature selection?

  4. Did they update the PWM duty-cycle to allow dimming to be less brightness?

@hapklaar
Copy link
Author

hapklaar commented Nov 3, 2022

Just received my second fan but the controller is different... The board has a new layout. I think it isn't possible to do the same thing with this board.

[edit] Hm the difference might be that I ordered the version without the light?

Received a new controller from Create as the light circuit on my old one died. It looks exactly the same as yours @fbloemhof. It is of the same type (T5HW), but has some extra wires and components for lamp control. So it seems it is their new module for both wifi versions.

I de-soldered the little daughter board and found what seems to be the same WBR3 tuya module, which could probably also be replaced by an ESP12 or similar.

image

@dennismaxjung how was your vacation and have you found new energy to do a little write-up? ;) Maybe I could 'translate' for this new version of the module.

@dennismaxjung
Copy link

dennismaxjung commented Nov 4, 2022

Hey @hapklaar I'm currently investigate some issues with my controller too, maybe my light circuit also dies. My light starts to flicker more and more.

I've also try to find out If i can make the "light smarter" with an additional chip to control the light temperature

I currently expanding my esphome config for use both of my RF remotes.

[edit:] I also investigate random turn on at night from the fan motor. It beeps and starts to spin. But no change is tracked by EspHomes console.
Also suddenly the ESP12 freezes and i have to switch on and of the curict breaker to restart the module.
This problem seems to have disapeard since the last esphome update, it seems to be some memory overflow...

What i notice it seems that the new boards have an integrated RF circuit 😥...

@dennismaxjung
Copy link

dennismaxjung commented Nov 4, 2022

@velzend

I have a couple questions:

  1. Are the states and/ or actions performed using the RF remote control are actually measurable via the GPIOs on the ESP12 board (applicable for the older/ previous fan controler)?

I've de-soldered the RF Module and soldered it back direct to the ESP12 so the RF Remotes are working directly over ESP-Home and not over the onboard tuya chip.

The ESP-12 Chip communicates over the ESPHome tuya-module-integration with the onboard tuya module

@dennismaxjung
Copy link

My second RF-Remote (a white one) does not work out of the box. It looks like my first one (Black-Buttons), sends RC-Switch codes and i can use them with esp home. The white-button one i have to look at the raw codes. But my environment here has a lot of 433mhz devices which interfere with my reciever. I have no idea how to remove this "jitter"

@dennismaxjung
Copy link

After i recoverd from my SSD crash on my host running home assistant and managed to recover the esphome yaml, i now can get back to work. I have to resolve the random reboots of the chip which i have know. it seems to have some kind of storage overload which ends in restarting the chip

@dennismaxjung
Copy link

I've uploaded the ESP-Home yaml to github:
https://gist.github.com/dennismaxjung/48325e3171b7f9e277fc8b062f7d8955

As soon I've have finished the complete setup and the guide, i will publish the link

@DanielWe2
Copy link

Thanks. I am looking forward to more details. Should be nice winter project to have a better fan for next summer.

@lieven121
Copy link

Hi

Is the rf only board the same without the wifi chip, e.g. could i but the rf version and just add a wifi chip myself its 30 euros cheaper

@jcgonzalezdelgado
Copy link

Thanks a lot to everyone, this post is amazing, exactly what I was looking for. One question on how you actually operate it: would be possible to bypass the light and control it directly from a wall switch? My plan is the following:

  • Have two cables into the ceiling, one with permanent 230v and another switched by the wall switch.
  • Connect the Fan controller to the permanent 230v and the switched to the bypassed light.

Long story short: is the light AC/DC and which voltage? I would like to keep the light with a manual switch (automated with a Shelly or similar) and being able to use the fan regardless of the state of the wall switch.

@dennismaxjung
Copy link

Hey @jcgonzalezdelgado,
I didn't check the voltage of thr light but i think it is not wall power.

The Motor and the light are both powerd over the same controller.
So i have unswitched power on the Controller ans added an shelly plus i4 to my wall switch and automate it ober Home assistant.

I will check the voltage on my spare controller and report. My plan ist to seperate or switch the entire light. As my light ist starting to flicker, maybe i add RGB 😜 ?

But this will be my Summer Project.

@jcgonzalezdelgado
Copy link

@dennismaxjung RGB is always good option. Especially if it's individually addressable LEDs with some cool effects using WLED 😝

I have to think about your option to wire it out, as one of the "promises" I made my wife is the basic functionality (like lights) should work regardless of the state of Home Assistant. This way, even if everything goes sideways and I'm on a work trip, basic stuff works.

Also was thinking to directly replace the light module with something like this:

https://www.beleuchtung.de/led-magnetmodul-led-20w-230v-d-16-5-cm-4000k/

should fit (it's 16.5 cm) and it's also magnetic. Goes directly to 230V AC, so I can attach it to the wall switch.

Please report your findings, I'm really interested into this.

@dennismaxjung
Copy link

@jcgonzalezdelgado
Same problem with my girlfriend. One day No light in our bedroom --> HomeAssistant was down.. Not a happy Day 😅

I thought about some web API at the esp8266 which then the Shelly can directly trigger. But i have not found this ability in the esphome documentation.

@dennismaxjung
Copy link

@dennismaxjung RGB is always good option. Especially if it's individually addressable LEDs with some cool effects using WLED 😝

I have to think about your option to wire it out, as one of the "promises" I made my wife is the basic functionality (like lights) should work regardless of the state of Home Assistant. This way, even if everything goes sideways and I'm on a work trip, basic stuff works.

Also was thinking to directly replace the light module with something like this:

https://www.beleuchtung.de/led-magnetmodul-led-20w-230v-d-16-5-cm-4000k/

should fit (it's 16.5 cm) and it's also magnetic. Goes directly to 230V AC, so I can attach it to the wall switch.

Please report your findings, I'm really interested into this.

I will Look about the size of the LED Ring from the Link. And will Order if it fits.. (Thanks god it's directly from Germany so no long waiting, as I'm also from Germany).
I also Look for Something Like this in the passt bur didn't find anything, so a big Thanks.🤩

@dennismaxjung
Copy link

Hi

Is the rf only board the same without the wifi chip, e.g. could i but the rf version and just add a wifi chip myself its 30 euros cheaper

@lieven121 as i have not seen the PCB of the rf only one I cant say anything about the possible transition..

@dennismaxjung
Copy link

Thanks a lot to everyone, this post is amazing, exactly what I was looking for. One question on how you actually operate it: would be possible to bypass the light and control it directly from a wall switch? My plan is the following:

  • Have two cables into the ceiling, one with permanent 230v and another switched by the wall switch.
  • Connect the Fan controller to the permanent 230v and the switched to the bypassed light.

Long story short: is the light AC/DC and which voltage? I would like to keep the light with a manual switch (automated with a Shelly or similar) and being able to use the fan regardless of the state of the wall switch.

@jcgonzalezdelgado

The original LED is about 13cm wide. 16cm will might be possible with a little wiggle. But less would bei better

The LED is dimmable and have ac power by max ≈ 112V. If dimmed its lower.

The Switch between light color ist only indicated by switching power on and off between a specific time span.

As i could not see the rating of the LED Power cables, a cable replacement for 230v will be needed. But should be done rather easily.

I've we do not find anything for replacement a Custom LED PCB might be possible, or a seperate led Controller for the original LED PCB, (maybe reverse engineer the original Controller)

For your information and the "wife-aprove-factor":
As i have the rf remote configured in esphome I can Control the light and the fan without HomeAssistant running, this might be also a backup for you if HA has problems and you are out of town)

@jcgonzalezdelgado
Copy link

Thanks a lot to everyone, this post is amazing, exactly what I was looking for. One question on how you actually operate it: would be possible to bypass the light and control it directly from a wall switch? My plan is the following:

  • Have two cables into the ceiling, one with permanent 230v and another switched by the wall switch.
  • Connect the Fan controller to the permanent 230v and the switched to the bypassed light.

Long story short: is the light AC/DC and which voltage? I would like to keep the light with a manual switch (automated with a Shelly or similar) and being able to use the fan regardless of the state of the wall switch.

@jcgonzalezdelgado

The original LED is about 13cm wide. 16cm will might be possible with a little wiggle. But less would bei better

The LED is dimmable and have ac power by max ≈ 112V. If dimmed its lower.

The Switch between light color ist only indicated by switching power on and off between a specific time span.

As i could not see the rating of the LED Power cables, a cable replacement for 230v will be needed. But should be done rather easily.

I've we do not find anything for replacement a Custom LED PCB might be possible, or a seperate led Controller for the original LED PCB, (maybe reverse engineer the original Controller)

For your information and the "wife-aprove-factor": As i have the rf remote configured in esphome I can Control the light and the fan without HomeAssistant running, this might be also a backup for you if HA has problems and you are out of town)

Thanks a lot! I've taken the time to analyze the ESPHome yaml and I think this would be sufficient with the RF Remote to get a high WAF. Will be reporting any news I have

@lieven121
Copy link

My findings so far

I bought the wifi version with light

The pcb looks like this (newer model)

20230304_135946.jpg

And the daughter board looks like this
20230304_135956.jpg

20230304_140001.jpg

The pinout is left to right on the main board

20230304_140118.jpg

Is 12v gnd
And i guess 2 communication channels

On the daughter board there are only 6 components
1 coil
2 resistors
2 capacitors
And a 5pin component [vcna1]

I wonder can i just attach any esp board with a 12v stepdown?

@treynaer
Copy link

Hi all,
Great topic, because of the information found here I was able to transform my Create Wind Calm to ESPHome.
I've added some things to the ESPHome script shared above that solves the speed control with the existing ESPHome version. It looks like the TuyaMCU in the fan is not initialised properly at boot, however this is solved with my additions.

Add this script:

  - id: setNightMode
    mode: restart
    then: 
      - lambda: id(tuya_device).set_integer_datapoint_value(62,1);

Call it on boot:

on_boot:
  priority: -100.0
  then:
    - fan.turn_off: fan_01        
    - light.turn_off: light_01
    - script.execute: setNightMode

Add a button for further use of the added Night Mode function:

button:
  - platform: template
    name: Night mode (minimal speed)
    on_press: 
      then:
        - script.execute: setNightMode

If you now turn on the fan from HA with a specific speed this will work. Also the correct speed is visualised in HA.

@christiaanderidder
Copy link

This discussion is pure gold. I recently purchased the same fan and wanted to say thanks to everyone who posted their experiences here.

Strangely enough my fan did not come with the dimmable light (see make-all/tuya-local#1976 for more info).

My overall experience with the fan is pretty bad, and I think that extends to the tuya ecosystem as a whole. When connected everything works for a while, but at some point the fan just disconnects and starts refusing connections using the tuya protocol (from the official app, tuya local and tinytuya). While the build quality of the fan is okay, the electronics are clearly generic "aliexpress" quality, so let that be a warning for any future buyers.

In the end I decided to give the ESP12F mod in this topic a go. A big thanks to @dennismaxjung for sharing his config.

I will see if I can post some personal experiences and pictures of the specific components once everything is up and running.

@christiaanderidder
Copy link

christiaanderidder commented Jun 23, 2024

Ass promised above some info and pictures of my ESPhome mod:

MCU type sticker
The motor control board
The motor control board. The area circled in red had the daughter board attached to it

The daugher board, desoldered WBR3 and ESP12F
The daugher board, desoldered WBR3 and ESP12F
The daugher board, desoldered WBR3 and ESP12F.

This was my first attempt at soldering a PCB, so sadly I tore off the pads of the daughter board while desoldering. In the end I had to connect everything up using wires instead.

More shoddy soldering
My shoddy soldering.

Despite the "repaired" traces and shoddy soldering above everything boots up as expected.
GPIO15 is connected to GND, EN is connected to VCC. TXD0, RXD0, VCC, GND to their respective pins on the daughter board. GPIO12 is reserved for the RF module as implemented in @dennismaxjung's config file, but I did not get to connecting the RF module up yet, first I wanted to make sure ESPHome worked as expected.

There seem to be a couple of different versions of this fan. My fan is not dimmable, so I had to remove the DP22 config.

I also ran into some problems with the MCU not reporting the speed control DP on startup, #7 (comment) fixed it for me.

My final ESP config with the speed control fix can be found here: https://gist.github.com/christiaanderidder/63d372143c3ede79a43cce9e41bbe11e

@christiaanderidder
Copy link

christiaanderidder commented Jun 24, 2024

I could not resist to dig in a little deeper and might have found the cause with issues related to speed not reporting correctly.

Indirectly I also managed to fix the remote (when not disconnected from MCU and directly connected to the ESP board).
It turned out that ESPhome does not process a specific status update type that the MCU sends to ESPhome, which means that it does not always receive correct information on the state of the MCU (e.g. current speed).

I have been running a custom fork of ESPhome with my fix and so far everything works without needing additional startup scripts as mentioned in #7 (comment).

My proposed changes to ESPHome can be found here: esphome/esphome#6980

@hellboy-wien
Copy link

hellboy-wien commented Jun 24, 2024

i am Updated my ESP Home to 2024.6.1 and also the Fan:
i am getting Errors like:
brave_I9cxNLbySO

My Config of the Fan:

substitutions:
  friendly_name: arbeitszimmer deckenventilator
  device_name: arbeitszimmer-deckenventilator
  device_id: arbeitszimmer_deckenventilator
  device_description: ESP12-F - CREATE WINDSTYLANCE DC ceiling fan with light, RF and WLAN

globals:
  - id: global_remaining_timer
    type: time_t
    restore_value: no
    initial_value: "0"

# Chip config
esphome:
  name: ${device_name}
  comment: ${device_description}
  platform: ESP8266
  board: esp12e
  on_boot:
    priority: -100.0
    then:
      - fan.turn_off: fan_01        
      - light.turn_off: light_01

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: on

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${device_name}"
    password: !secret fallback_ap_password

# Enable logging
logger:
  baud_rate: 0 #Disable UART logging

# Enable Home Assistant API
api:
  encryption: 
    key: !secret api_key

# Enable over the air updates
ota:
  - platform: esphome
    password: !secret ota_password

captive_portal:

# see: https://esphome.io/components/time.html
time:
  - platform: homeassistant
    id: homeassistant_time

# Enable Web server
web_server:
  port: 80

# Device specific configuration
# CREATE - WINDSTYLANCE DC - ceiling fan


uart:
  rx_pin: GPIO3
  tx_pin: GPIO1
  baud_rate: 9600

# Register the Tuya MCU connection
tuya:
  time_id: homeassistant_time
  
remote_receiver:
  pin: GPIO12
  dump:
    - rc_switch
    - nexa

fan:
  - platform: "tuya"
    id: fan_01
    name: "${device_name} Fan"
    switch_datapoint: 60
    speed_datapoint: 62
    direction_datapoint: 63
    speed_count: 6
    restore_mode: ALWAYS_OFF

# Create a light using the dimmer
light:
  - platform: "tuya"
    id: light_01
    name: "${device_name} Licht"
    switch_datapoint: 20
    warm_white_color_temperature: 500 mireds
    cold_white_color_temperature: 152 mireds
    color_temperature_datapoint: 23
    color_temperature_max_value: 1000.0
    color_temperature_invert: false
    max_value: 1000
    dimmer_datapoint: 22
    restore_mode: ALWAYS_OFF

text_sensor:
  - platform: version
    name: "${device_name} Version"
    icon: mdi:cube-outline
  - platform: template
    name: "${device_name} Timer remaind"
    id: "fan_timer_remains"
    icon: mdi:timelapse

binary_sensor:
  - platform: status
    name: "${device_name} Status"
    device_class: connectivity
  - platform: remote_receiver
    id: "power"
    rc_switch_raw:
      code: '000011011001111100001000'
      protocol: 4
    on_press:
      then:
        - fan.toggle: 
            id: fan_01
        - script.stop: fan_one_hour_script
        - script.stop: fan_two_hour_script
        - script.stop: fan_four_hour_script
        - script.stop: fan_eight_hour_script
  - platform: remote_receiver
    id: "direction"
    rc_switch_raw:
      code: '101010101111011000001110'
      protocol: 4
    on_press:
      then:
        - if:
            condition:
              - lambda:  return id(fan_01).direction == FanDirection::FORWARD;
            then:
              - fan.turn_on: 
                  id: fan_01
                  direction: REVERSE
            else:
              - fan.turn_on: 
                  id: fan_01
                  direction: FORWARD
  - platform: remote_receiver
    id: "oneHour"
    rc_switch_raw:
      code: '101010101111011000001101'
      protocol: 4
    on_press:
      then:
        - lambda: id(global_remaining_timer) = 0;
        - script.execute: fan_one_hour_script
        - script.stop: fan_two_hour_script
        - script.stop: fan_four_hour_script
        - script.stop: fan_eight_hour_script
  - platform: remote_receiver
    id: "twoHour"
    rc_switch_raw:
      code: '101010101111011000001111'
      protocol: 4
    on_press:
      then:
        - lambda: id(global_remaining_timer) = 0;
        - script.stop: fan_one_hour_script
        - script.execute: fan_two_hour_script
        - script.stop: fan_four_hour_script
        - script.stop: fan_eight_hour_script
  - platform: remote_receiver
    id: "fourHour"
    rc_switch_raw:
      code: '101010101111011000010000'
      protocol: 4
    on_press:
      then:
        - lambda: id(global_remaining_timer) = 0;
        - script.stop: fan_one_hour_script
        - script.stop: fan_two_hour_script
        - script.execute: fan_four_hour_script
        - script.stop: fan_eight_hour_script
  - platform: remote_receiver
    id: "eightHour"
    rc_switch_raw:
      code: '101010101111011000010010'
      protocol: 4
    on_press:
      then:
        - lambda: id(global_remaining_timer) = 0;
        - script.stop: fan_one_hour_script
        - script.stop: fan_two_hour_script
        - script.stop: fan_four_hour_script
        - script.execute: fan_eight_hour_script
  - platform: remote_receiver
    id: "decrease_speed"
    rc_switch_raw:
      code: '101010101111011000001011'
      protocol: 4
    on_press:
      then:
        - if:
            condition:
              - lambda: return id(fan_01).speed > 1;
            then:
              - fan.turn_on: 
                  id: fan_01
                  speed: !lambda return id(fan_01).speed - 1;
  - platform: remote_receiver
    id: "increase_speed"
    rc_switch_raw:
      code: '101010101111011000000101'
      protocol: 4
    on_press:
      then:
        - if:
            condition:
              - lambda:  return id(fan_01).speed < 6;
            then:
              - fan.turn_on: 
                  id: fan_01
                  speed: !lambda return id(fan_01).speed + 1;
  - platform: remote_receiver
    id: "decrease_light"
    rc_switch_raw:
      code: '101010101111011000000111'
      protocol: 4
    on_press:
      then:
        - light.dim_relative:
            id: light_01
            relative_brightness: -15%
  - platform: remote_receiver
    id: "increase_light"
    rc_switch_raw:
      code: '101010101111011000001001'
      protocol: 4
    on_press:
      then:
        - light.dim_relative:
            id: light_01
            relative_brightness: 15%
  - platform: remote_receiver
    id: "toggle_light"
    rc_switch_raw:
      code: '101010101111011000000001'
      protocol: 4
    on_press:
      then:
        - light.toggle: light_01
  - platform: remote_receiver
    id: "change_light"
    rc_switch_raw:
      code: '101010101111011000000011'
      protocol: 4
    on_press:
      then:
        - light.control: 
            id: light_01
            color_temperature: !lambda return 200.0;  

script:
  - id: fan_one_hour_script
    mode: restart
    then:
      - lambda: id(global_remaining_timer) = id(homeassistant_time).now().timestamp + 3600;
      - fan.turn_on: fan_01
      - delay: 1 h
      - fan.turn_off: fan_01
      - lambda: id(global_remaining_timer) = 0;
  - id: fan_two_hour_script
    mode: restart
    then:
      - lambda: id(global_remaining_timer) = id(homeassistant_time).now().timestamp + 7200;
      - fan.turn_on: fan_01
      - delay: 2 h
      - fan.turn_off: fan_01
      - lambda: id(global_remaining_timer) = 0;
  - id: fan_four_hour_script
    mode: restart
    then:
      - lambda: id(global_remaining_timer) = id(homeassistant_time).now().timestamp + 14400;
      - fan.turn_on: fan_01
      - delay: 4 h
      - fan.turn_off: fan_01
      - lambda: id(global_remaining_timer) = 0;
  - id: fan_eight_hour_script
    mode: restart
    then:
      - lambda: id(global_remaining_timer) = id(homeassistant_time).now().timestamp + 28800;
      - fan.turn_on: fan_01
      - delay: 8 h
      - fan.turn_off: fan_01
      - lambda: id(global_remaining_timer) = 0;

sensor:
  - platform: wifi_signal
    name: "${device_name} Wifi Signal"
    update_interval: 60s
    icon: mdi:wifi

  - platform: uptime
    name: "${device_name} Uptime Seconds"
    update_interval: 60s
    icon: mdi:clock-outline

  - platform: template
    update_interval: 30s
    id: "fan_timer_remains_raw"
    lambda: |-
      if (id(global_remaining_timer) == 0) {
        return 0;
      } else {
        return round(id(global_remaining_timer) - id(homeassistant_time).now().timestamp);
      }
    on_raw_value:
      then:
        - text_sensor.template.publish:
            id: fan_timer_remains
            state: !lambda |-
              int seconds = id(fan_timer_remains_raw).raw_state;
              int days = seconds / (24 * 3600);
              seconds = seconds % (24 * 3600);
              int hours = seconds / 3600;
              seconds = seconds % 3600;
              int minutes = seconds /  60;
              seconds = seconds % 60;
              return (
                (days ? to_string(days) + "d " : "") +
                (hours ? to_string(hours) + "h " : "") +
                (minutes ? to_string(minutes) + "m " : "") +
                (to_string(seconds) + "s")
              ).c_str();
              
switch:
  - platform: restart
    name: "${device_name} Restart"
  - platform: template
    name: "${device_name} Fan 1h Timer"
    device_class: switch
    id: "fan_one_hour_shutdown"
    icon: mdi:timelapse
    lambda: !lambda |-
      if(id(fan_one_hour_script).is_running()) {
        return true;
      } else {
        return false;
      }
    turn_on_action:
      - script.execute: fan_one_hour_script
      - script.stop: fan_two_hour_script
      - script.stop: fan_four_hour_script
      - script.stop: fan_eight_hour_script
    turn_off_action:
      - script.stop: fan_one_hour_script
      - lambda: id(global_remaining_timer) = 0;
  - platform: template
    name: "${device_name} Fan 2h Timer"
    device_class: switch
    id: "fan_two_hour_shutdown"
    icon: mdi:timelapse
    lambda: !lambda |-
      if(id(fan_two_hour_script).is_running()) {
        return true;
      } else {
        return false;
      }
    turn_on_action:
      - script.stop: fan_one_hour_script
      - script.execute: fan_two_hour_script
      - script.stop: fan_four_hour_script
      - script.stop: fan_eight_hour_script
    turn_off_action:
      - script.stop: fan_two_hour_script
      - lambda: id(global_remaining_timer) = 0;
  - platform: template
    name: "${device_name} Fan 4h Timer"
    device_class: switch
    id: "fan_four_hour_shutdown"
    icon: mdi:timelapse
    lambda: !lambda |-
      if(id(fan_four_hour_script).is_running()) {
        return true;
      } else {
        return false;
      }
    turn_on_action:
      - script.stop: fan_one_hour_script
      - script.stop: fan_two_hour_script
      - script.execute: fan_four_hour_script
      - script.stop: fan_eight_hour_script
    turn_off_action:
      - script.stop: fan_four_hour_script
      - lambda: id(global_remaining_timer) = 0;
  - platform: template
    name: "${device_name} Fan 8h Timer"
    device_class: switch
    id: "fan_eight_hour_shutdown"
    icon: mdi:timelapse
    lambda: !lambda |-
      if(id(fan_eight_hour_script).is_running()) {
        return true;
      } else {
        return false;
      }
    turn_on_action:
      - script.stop: fan_one_hour_script
      - script.stop: fan_two_hour_script
      - script.stop: fan_four_hour_script
      - script.execute: fan_eight_hour_script
    turn_off_action:
      - script.stop: fan_eight_hour_script
      - lambda: id(global_remaining_timer) = 0;
``

@christiaanderidder
Copy link

christiaanderidder commented Jun 25, 2024

@hellboy-wien I wonder if it's an issue with the timer logic using up memory. Because here everything runs very smoothly and I am using a simpler config file. I removed the timer logic since I don't really use it, but am considering to add it again using the built-in timer instead (as the timer via the remote would do). The logic for the remote can also be removed if you run ESPhome with my fix, as ESPhome does not need to handle any remote signals, it will just receive the updates from the MCU when the remote is used.

This is the config file I'm currently using. As you can see there is no need for additional startup scripts, nor any logic for the remote.

external_components:
  # Use custom tuya fork that fixes issues with data point updates coming from MCU
  - source:
      type: git
      url: https://github.com/christiaanderidder/esphome
      ref: "tuya-invalid-command-0x22"
    components: [ tuya ]

substitutions:
  friendly_name: Bedroom Ceiling Fan
  device_name: bedroom-ceiling-fan
  device_id: bedroom_ceiling_fan
  device_description: ESP12F - CREATE WINDCALM Fan

esphome:
  name: ${device_name}
  comment: ${device_description}
  friendly_name: ${friendly_name}
  
esp8266:
  board: esp01_1m

# Enable logging
logger:
  #level: VERBOSE
  baud_rate: 0 # Disable UART logging

# Enable Home Assistant API
api:
  encryption:
    key: !secret encryption_key

ota:
  - platform: esphome
    password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: on # Don't scan networks, connect straight away
  manual_ip:
    static_ip: 10.0.20.11
    gateway: 10.0.0.1
    subnet: 255.255.0.0
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: ${device_name}
    password: !secret fallback_ap_password

# Enable web server
web_server:
  port: 80

# Sync time with home assistant
time:
  - platform: homeassistant
    id: homeassistant_time

# Device specific configuration
# CREATE - WINDCALM DC - ceiling fan

uart:
  rx_pin: GPIO3
  tx_pin: GPIO1
  baud_rate: 9600
  #debug:
  
# Register the Tuya MCU connection
tuya:
  id: "tuya_device"
  time_id: homeassistant_time

fan:
  - platform: "tuya"
    id: fan_device
    name: "Fan"
    switch_datapoint: 60
    speed_datapoint: 62
    direction_datapoint: 63
    speed_count: 6
    restore_mode: ALWAYS_OFF

light:
  - platform: "tuya"
    id: light_device
    name: "Light"
    switch_datapoint: 20
    restore_mode: ALWAYS_OFF

text_sensor:
  - platform: version
    name: "Version"
    icon: mdi:cube-outline

binary_sensor:
  - platform: status
    name: "Status"
    device_class: connectivity

sensor:
  - platform: wifi_signal
    name: "Wifi Signal"
    update_interval: 60s
    icon: mdi:wifi

  - platform: uptime
    name: "Uptime Seconds"
    update_interval: 60s
    icon: mdi:clock-outline

@hellboy-wien
Copy link

hellboy-wien commented Jun 25, 2024

@christiaanderidder THANK YOU
With your configuration I can finally change the speed.
Now I just have to get the remote control to work, do you have any ideas?
In the meantime I will replace the LED (because of the color cycle) and will remove the code for light.

substitutions:
  friendly_name: arbeitszimmer deckenventilator
  device_name: arbeitszimmer-deckenventilator
  device_id: arbeitszimmer_deckenventilator
  device_description: ESP12-F - CREATE WINDSTYLANCE DC ceiling fan 

esphome:
  name: ${device_name}
  comment: ${device_description}
  friendly_name: ${friendly_name}
  on_boot:
    priority: -100.0
    then:
      - script.execute: set_speed
      - fan.turn_off: fan_01
      - light.turn_off: light_01

esp8266:
  board: esp01_1m

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: on

  ap:
    ssid: "${device_name}"
    password: !secret fallback_ap_password

logger:
  baud_rate: 0

api:
  encryption: 
    key: !secret api_key

ota:
  - platform: esphome
    password: !secret ota_password

time:
  - platform: homeassistant
    id: homeassistant_time

web_server:
  port: 80

uart:
  rx_pin: GPIO3
  tx_pin: GPIO1
  baud_rate: 9600

tuya:
  id: "tuya_device"
  time_id: homeassistant_time

# Sets the fan speed manually on startup, otherwise the fan control does not work properly
script:
  - id: set_speed
    mode: restart
    then: 
      - lambda: id(tuya_device).set_integer_datapoint_value(62, 1);

fan:
  - platform: "tuya"
    id: fan_01
    name: "${device_name} Fan"
    switch_datapoint: 60
    speed_datapoint: 62
    direction_datapoint: 63
    speed_count: 6
    restore_mode: ALWAYS_OFF

light:
  - platform: "tuya"
    id: light_01
    name: "${device_name} Licht"
    switch_datapoint: 20
    restore_mode: ALWAYS_OFF

text_sensor:
  - platform: version
    name: "${device_name} Version"
    icon: mdi:cube-outline

binary_sensor:
  - platform: status
    name: "${device_name} Status"
    device_class: connectivity

sensor:
  - platform: wifi_signal
    name: "${device_name} Wifi Signal"
    update_interval: 60s
    icon: mdi:wifi

  - platform: uptime
    name: "${device_name} Uptime Seconds"
    update_interval: 60s
    icon: mdi:clock-outline

@christiaanderidder
Copy link

christiaanderidder commented Jun 25, 2024

@hellboy-wien For me the remote works without issues after my changes to the ESPHome code (edit: esphome/esphome#6980 has been merged to the dev branch so it should show up in a upcoming release). Keep in mind that I did not desolder the RF board from the MCU board. So i also did not connect the RF board directly to the ESP chip. When I use the remote the MCU reports the updates to ESPhome over TX/RX (using the command fixed in my ESPhome fork). It's logged as the 0x22 command when that happens.

However, if there is one thing i learned from this thread, it's that there are a whole bunch of variants of the hardware in this fan (different boards, different remotes), so yours might not be the same as mine. I think they just get any chinese components available at the time of production and consistency does not matter much. Never another tuya based product for me that's for sure 😅

@Kaaf76
Copy link

Kaaf76 commented Jun 27, 2024

@hellboy-wien I wonder if it's an issue with the timer logic using up memory. Because here everything runs very smoothly and I am using a simpler config file. I removed the timer logic since I don't really use it, but am considering to add it again using the built-in timer instead (as the timer via the remote would do). The logic for the remote can also be removed if you run ESPhome with my fix, as ESPhome does not need to handle any remote signals, it will just receive the updates from the MCU when the remote is used.

This is the config file I'm currently using. As you can see there is no need for additional startup scripts, nor any logic for the remote.

@christiaanderidder
Your solution works excellent. Even when using the (433mhz) remote the value is copied in esphome (and home assistant), without having to remove the 433mhz receiver!!!! I hope this will be my final tweak for the this "hoofdpijn dossier".
Case closed for me!! Thanks

@hellboy-wien
Copy link

Hello, I'm currently fine-tuning my code. Is it possible to start a script from ESP Home, like when I press the 1h, 4h, 8h buttons on the remote control. And also to create a sensor to show how long the remaining runtime is?

@alexandrebelloni
Copy link

Hello,

I'm wondering where you were all able to order the controller from, I've search and couldn't find any controller with the same reference. I currently have a windcalm without wifi and I'd like to order the wifi controller and d the mod.

@bailen22
Copy link

bailen22 commented Jul 3, 2024

Hello,

I'm wondering where you were all able to order the controller from, I've search and couldn't find any controller with the same reference. I currently have a windcalm without wifi and I'd like to order the wifi controller and d the mod.

Hi @alexandrebelloni.

I've just bought one on Saturday on Amazon Spain and received yesterday. Now there is no stock:

TECHBREY Controlador para Ventilador de Techo DC con Mando Seleccionable (Cálido-Neutro-Frío)
https://www.amazon.es/dp/B0B97CKNCD?ref=cm_sw_r_apan_dp_EKVK6QHBESB4E8ZA64WV

The model is: Fan Light Controller model: 6601TL

01

02

Tomorrow I will disassembly and show the PCB.

@hellboy-wien
Copy link

@dennismaxjung Hallo. I have now also used parts of your code because I would like to use the timers 1, 2, 4, 8 hours. And this creates the sensor: timer remaining. This updates every ~30 seconds. Is it possible to round the value or only display it when exactly 1 minute has passed? Because I would like to have a bar like this in the dashboard and an even number... Do you have any ideas? Danke dir!!!

@christiaanderidder
Copy link

I decided to create a repo containing a guide to modding the fan to ESPHome and all the configuration files I used, based on the experiences here: https://github.com/christiaanderidder/esphome-create-wind-calm.

@velzend
Copy link
Owner

velzend commented Jul 15, 2024

@christiaanderidder thanks for sharing!

@Chojinodebahia
Copy link

I did the mod with an esp12f, library works awesome but I encounter a problem I did not expect. Mi wifi antenna is pretty close to the fan but both ceiling support plate and enclosure are metal made and guess what, it acts as some kind of Faraday cell so as soon as I mount the fan, 0 wifi signal! I'm planning to solder an external antenna, I also bought and esp32s with external antenna just in case, wish me luck.

IMG_8689 en tamaño mediano
IMG_8690 en tamaño mediano
IMG_8691 en tamaño mediano
IMG_8695 en tamaño mediano
D521CE23-7918-43E0-99B5-52CD5C34B31D

@velzend
Copy link
Owner

velzend commented Jul 15, 2024

That could be the issue indeed. Maybe the onboard antenna has a very bad SWR in the 2,4Ghz. band. If possible try changing the wifi channel first or the location of your wifi router/ap. Otherwise replace the antenna with an external one this could be a copper wire cut to exactly 28.8 (max. 32) mm (wave length) if you have or can borrow a meter for the 2.4GHz or a NanoVNA you can measure the SWR.

@zindy
Copy link

zindy commented Jul 16, 2024

Hello,

I just received my Wind Calm package today and took some pictures of the controller, which is slightly different from the ones in this thread. I ordered my fan without internet control.
20240716_212426
20240716_212455
20240716_212521
20240716_215523
20240716_215557
20240716_215638
20240716_215650
20240716_215705
20240716_215716

Edit: Just a quick comparison between the WIFI version on the left (photograph above from @christiaanderidder) and the non-WIFI version on the right.

image1

If my photographs are any use to you, feel free to use them as you please.

@christiaanderidder
Copy link

ESPHome 2024.7 has been released which contains a fix for the issues initializing the device.
I've updated the sample config in my repository: https://github.com/christiaanderidder/esphome-create-wind-calm/blob/main/esphome/ceiling-fan.yaml

This means that:

  • Custom scripts like the example below are not necessary to make the fan speed work properly.
  • The RF receiver for the remote does not have to be desoldered and connected directly to the ESP12-F
# Sets the fan speed manually on startup, otherwise the fan control does not work properly
script:
  - id: set_speed
    mode: restart
    then: 
      - lambda: id(tuya_device).set_integer_datapoint_value(62, 1);

@schumy1606
Copy link

Thank you guys for your great work. I just updated two fans based on your latest instructions and both fans are working great. No more sending data to China. The only obstacle was the VCC connection to EN. Here it did not work when soldering the EN of the ESP3266 to the corresponding connection on the daughter board. With an additional connection directly to VCC it worked fine.

@gedas07
Copy link

gedas07 commented Jul 26, 2024

Hello, I have this fan with tuya controller and I want to change it for the ESPhome, but I wanted to know before doing so if the fan speeds and turning the light on and off would work well,
And if everything will be visible in Home Assistant?
IMG_7990
IMG_7992

@christiaanderidder
Copy link

Hello, I have this fan with tuya controller and I want to change it for the ESPhome, but I wanted to know before doing so if the fan speeds and turning the light on and off would work well, And if everything will be visible in Home Assistant?

Fan speed works fine, some people had issues because of ESPhome not correctly parsing a message from the motor controller, but that has been fixed in the latest ESPhome version.
Turning the light on and off also works fine, with one remark. The color temperature of the light (white, medium warm and warm) changes every time the light is switched off and on rapidly. This is just a limitation of how the LED component itself works. Some people have replaced the entire light. When using the light normally it's not a huge issue.

Everything shows up in Home Assistant as expected.

@al3xt3r
Copy link

al3xt3r commented Jul 29, 2024

Note: there are different controllers that look very simlar but work differently.

I was not able to connect to the tuya MCU in a controller with the designation
RXPEP(WIFI80-200)RPM . (bought from techbray via amazon as wifi with tuya)

With a controller called RXAL(WIFI80-200)RPM the same ESP and code do work fine.

@kubert96
Copy link

kubert96 commented Aug 1, 2024

I have a questiion. I bougt sam cieling fan. And it looks like from the first pictures with only 4 pin header.
Coud this be controled?

Main control: RDI32F036M6S8 (96MHz, 2 OPAs)

Its got pinout like: 5V UP, RX? , TX?, GND

I tried your code. But i only get:
[14:08:43][E][tuya:464]: Initialization failed at init_state 0
[14:08:58][E][tuya:464]: Initialization failed at init_state 0

So maby i missing something.
I dont realy know if this controler can be controld or if this is only a Flashing port.

In first pictures you to have only 4 pin conector and ESP conected to it.

IMG_4107
IMG_4177
IMG_4179
IMG_4178

@werneru
Copy link

werneru commented Aug 14, 2024

Many thanks to christiaanderidder and also to dennismaxjung for starting this one!
I got it running with the CasaFan Eco Neo WiFi and also for the CasaFan Concept WiFi. It is quite easy to replace the chip, flash the ESP12F outside and solder it in place. I used the yaml from ChristiaandeRidder and had to adapt the correct datapoints. I included also a switch for the direction but here I have a problem:

Error message:
[tuya:628] | Attempt to set datapoint 8 with incorrect type

switch:

  • platform: "tuya"
    id: direction
    name: "Revers"
    switch_datapoint: 8

Christiaan, Dennis, any ideas??

@werneru
Copy link

werneru commented Aug 14, 2024

And here is the part with the datapoints for the CasaFan Eco Neo and Concept WiFi:fan:

  • platform: "tuya"
    id: fan_device
    name: "Fan"
    switch_datapoint: 1
    speed_datapoint: 3
    direction_datapoint: 8
    speed_count: 6
    restore_mode: ALWAYS_OFF

light:

  • platform: "tuya"
    id: light_device
    name: "Light"
    switch_datapoint: 15
    restore_mode: ALWAYS_OFF

switch:

  • platform: "tuya"
    id: direction
    name: "Revers"
    switch_datapoint: 8

@werneru
Copy link

werneru commented Aug 14, 2024

Ib got it fixed; Tuya asks for enum ....
select:

  • platform: "tuya"
    name: "Fan Direction"
    id: fan_direction
    enum_datapoint: 8
    options:
    0: "Forward"
    1: "Reverse"

@gedas07
Copy link

gedas07 commented Aug 14, 2024

Hello, I have this fan with tuya controller and I want to change it for the ESPhome, but I wanted to know before doing so if the fan speeds and turning the light on and off would work well, And if everything will be visible in Home Assistant?

Fan speed works fine, some people had issues because of ESPhome not correctly parsing a message from the motor controller, but that has been fixed in the latest ESPhome version. Turning the light on and off also works fine, with one remark. The color temperature of the light (white, medium warm and warm) changes every time the light is switched off and on rapidly. This is just a limitation of how the LED component itself works. Some people have replaced the entire light. When using the light normally it's not a huge issue.

Everything shows up in Home Assistant as expected.

Thanks a lot for your answer ,
I think I'll try it in a few days, I hope I don't break it by unsoldering tuya chip.

@werneru
Copy link

werneru commented Aug 15, 2024

Hi, from HA side every thing works well. I do not use the light dimming part nor the timer function. Sometimes the speed on the remote gets out of sync with the speed in HA; the remote shows a speed of 1 and in HA it is still at 4....
Regarding unsoldering; I used a very thin cutter knife blade and pushed it under the antenna part. Then put extra solder on one side and heated it by going several times forth and back on the pins with the solder iron and lifted the one side 2mm and than the same for the other side. But every one has his own technique for that...

@silkimen
Copy link

silkimen commented Sep 6, 2024

Hi guys, first of all thank you for sharing those invaluable findings!

Today I received my Create Windcalm with RC and w/o WIFI control and mounted it. I have a KNX setup here and I thought turning on/off the AC connection will just turn on/off the ventilator using last speed config. But unfortunately that's not the case. 😣

Now I thought maybe I can attach an external board which can bridge the device with KNX (e.g. using a custom made Konnekting board). I have exactly the same board that @zindy posted in his post above. So this device does not have a WBR3 daughter board, but it does have the connector CN2 which seems to be a data connector. Did anyone try to figure out what this connector is meant for?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests