Control multiple fans as one entity

I have multiple PWM fan’s that I’m successfully controlling in HA via ESPHome. However these fans are separate entities. How can they be controlled as one entity in HA and still support changing fan speed? Below is the code I currently have

output:
  - platform: ledc
    pin: GPIO23
    frequency: 10000 Hz
    id: test_fan_pwm1
  - platform: ledc
    pin: GPIO21
    frequency: 10000 Hz
    id: test_fan_pwm2

fan:
  - platform: speed
    output: test_fan_pwm1
    name: "Test Fan 1"
  - platform: speed
    output: test_fan_pwm2
    name: "Test Fan 2"

Any help appreciated, thanks!

I think you can combine these in HA using the template fan integration. For this to work you should first create scripts to select speeds. You should have to be carefull as the speed here are in percentages, the details are there in the docs but if you need any more help, do ask.

There could be some method in esphome also but I am not aware of that.

Hi hummingbear,

although this question is already 3 years old I was wondering if you’ve found a solution for that. I have exactly the same config and I’m trying to find a solution for that (one controller in the frontend to manage both fans).

I don’t recall as I don’t use those fans anymore, but looking at the HomeAssistant documentation you could use a Template Fan it seems

fan:
  - platform: template
    fans:
      battery_fans:
        friendly_name: "Combined Battery Fans"
        value_template: "{{ is_state('fan.battery_fan_1', 'on') and is_state('fan.battery_fan_2', 'on') }}"
        turn_on:
          - service: fan.turn_on
            target:
              entity_id:
                - fan.battery_fan_1
                - fan.battery_fan_2
        turn_off:
          - service: fan.turn_off
            target:
              entity_id:
                - fan.battery_fan_1
                - fan.battery_fan_2
        percentage_template: >
          {{ state_attr("fan.battery_fan_1", "percentage") if is_state('fan.battery_fan_1', 'on') else 0 }}
        speed_count: 3
        set_percentage:
          - service: fan.turn_{{ 'on' if percentage > 0 else 'off' }}
            target:
              entity_id:
                - fan.battery_fan_1
                - fan.battery_fan_2
          - service: fan.set_percentage
            target:
              entity_id:
                - fan.battery_fan_1
                - fan.battery_fan_2
            data:
              value: "{{ percentage }}"

The percentage template is totally optional but allows your to adjust the speed of the fans (if they support it).

Also in ESPHome you could assign one PWM controller to multiple fans:

output:
  - platform: ledc
    pin: GPIO18
    frequency: 10000 Hz
    id: battery_box_fans

fan:
  - platform: speed
    output: battery_box_fans
    name: "Battery Box Fans"

where GPIO18 is assigned to one PWM controller that is connected to multiple fans.

There might also be a way to have ESPHome config to use one “Fan” that points to multiple PWM fans, but you’ll have to experiment.