PWM Fan ramp up on boot

Good day!

I would like to ramp up PWM Fans on boot like they do in PCs. When the device starts it should start the Fans at full speed for about 5 seconds and then return to the previously set speed. However none of the approaches I tried so far worked at all.

esphome:
  name: cabinet
  friendly_name: Cabinet
  on_boot:
    priority: 900
    then:
      - script.execute: fan1_init
      - fan.turn_on: fan2
      - fan.turn_on: fan3

esp32:
  board: esp32dev
  framework:
    type: arduino

logger:
  level: INFO

api:
  encryption:
    key: !secret cabinet_api_key

ota:
  password: !secret cabinet_ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true
  manual_ip:
    static_ip: !secret cabinet_ip
    subnet: !secret ip4_mask
    gateway: !secret ip4_gateway
    dns1: !secret ip4_dns1
    dns2: !secret ip4_dns2

script:
  - id: fan1_init
    mode: single
    then:
      # - output.set_level:
      #     id: pwm1
      #     level: 100%
      # - delay: 5s
      # - output.set_level:
      #     id: pwm1
      #     level: 50%
      - fan.turn_on:
          id: fan1
          speed: 10
      - delay: 5s
      - fan.turn_on:
          id: fan1
          speed: 5

output:
  - platform: ledc # pwm for a fan
    id: pwm1
    pin: GPIO2
    inverted: true # mosfet pulldown inverts signal
    frequency: 25000Hz
    min_power: 10% # pwm fan standard requires minimum signal
    max_power: 100%

  - platform: ledc # pwm for a fan
    id: pwm2
    pin: GPIO4
    inverted: true # mosfet pulldown inverts signal
    frequency: 25000Hz
    min_power: 10% # pwm fan standard requires minimum signal
    max_power: 100%

  - platform: ledc # pwm for a fan
    id: pwm3
    pin: GPIO16
    inverted: true # mosfet pulldown inverts signal
    frequency: 25000Hz
    min_power: 10% # pwm fan standard requires minimum signal
    max_power: 100%

fan:
  - platform: speed
    id: fan1
    name: "Fan FL"
    output: pwm1
    speed_count: 10
    restore_mode: RESTORE_DEFAULT_ON
    on_turn_off:
      - fan.turn_on: fan1 # don't allow turning off

  - platform: speed
    id: fan2
    name: "Fan FR"
    output: pwm2
    speed_count: 10
    restore_mode: RESTORE_DEFAULT_ON
    on_turn_on:
      - output.set_level:
          id: pwm2
          level: 100%
      - delay: 5s
      - output.set_level:
          id: pwm2
          level: 50%
    on_turn_off:
      - fan.turn_on: fan2 # don't allow turning off

  - platform: speed
    id: fan3
    name: "Fan BL"
    output: pwm3
    speed_count: 10
    restore_mode: ALWAYS_OFF
    on_turn_on:
      - output.set_level:
          id: pwm3
          level: 100%
      - delay: 5s
      - output.set_level:
          id: pwm3
          level: 50%
    on_turn_off:
      - fan.turn_on: fan3 # don't allow turning off

Many Greetings!
Remo

Welcome fleckingerre.

Do these commands work ok when the fan has fully booted (say via a button:?).

What is currently happening on_boot:?

Have you tried a lower priority?

What does the documentation say?

Hi Mahko!

Thank you for a constructive reply.

The commands should also be executed when turning off the fan, since the on_turn_off event handler turns it on again, which in turn should trigger the on_turn_on event handler. This also didn’t work. I didn’t test it with a button since this is not a relevant scenario.

During boot the pwm is started at 50% and it remains there.

I have tried different priorities. Delivering an example for every combination I tried would be out of scope and no one would read that amount of text.

.

I solved this with a template number in the mean time and just start at 100% (save fail), since it’s anyways impossible to configure the fan component exactly how I want it. It’s not possible to remove or disable the turn-off switch and the boot ramp should be a config option for the speed fan component, since it should be standard behaviour for speed controlled fans. So this thread merely remains as a bug report to the devs.

Many Greetings!
Remo