Looking to read multiple remote controled fans with one esp

Hi,

I’ve successfully write yaml+code to control the set of fans that I have by emitting the proper codes. Now I’d like to also catch the use of the remotes to reflect the state of the fans in Home Assistant. I’ve had no issue creating a binary_sensor that can recognize the button press, but I’m falling short of having that affect the state of the fan.

The relevant bits from my main file:


remote_transmitter:
  - pin: 
      number: 5 # This is GDO0
      allow_other_uses: true
    carrier_duty_percent: 100%

remote_receiver:
  - pin: 
      number: 5 # This is GDO0
      allow_other_uses: true
    dump:
      - raw

binary_sensor:
  - platform: remote_receiver
    name: Garage
    raw:
      code: [346,-692,346,-692,346,-692,346,-692,346,-346,692,-692,346,-692,346,-692,
        346,-692,346,-692,346,-346,692,-692,346]

packages:
  family_room_fan: !include
    file: minkaair.yaml
    vars:
      device_id: family_room_fan
      device_name: Family Room Fan
      device_code: "0b1000"

Finaly, the package file that is referenced:

# https://github.com/dbuezas/esphome-cc1101
output:
  - platform: template
    type: float
    id: ${device_id}_output
    write_action:
      - lambda: get_cc1101(transciver).beginTransmission();
      - remote_transmitter.transmit_raw:
          repeat:
            times: 5
            wait_time: 12.12ms
          code: !lambda return getMinkaAirCodes(${device_code}, round(state * 3));
      - lambda: get_cc1101(transciver).endTransmission();

fan:
  - platform: speed
    output: ${device_id}_output
    name: ${device_name}
    icon: mdi:fan
    speed_count: 3
    id: ${device_id}

What I would ultimately like is something to the effect of an input device where I could specify “input: …” and essentially copy most of the output details but for the purpose setting the fan’s set through the reception of RF codes. Arguably you could do this in home assistant by creating a unique binary sensor and having it change the state of the fan, but that’s rather ugly imo since it would require Home Assistant to be aware of every code for every speed setting instead of having it fully contained on the esp chip. Is there a clean way to achieve this? I’m also not a fan of exposing a binary sensor when there’s really no need for HA to be aware of it directly.

Perhaps you could dig into the source code for one of the climate ir remotes that support a reciever and fan speed and see how it is implemented there?

https://esphome.io/api/mitsubishi_8h_source

So… Push a button on remote and you want binary_sensor to see that and also keep track of the states?

Why would you even consider making additional sensors in HA to track the states? You already have binary_sensors for each button or atleast you’ve started on that.

Here is a binary_sensor for 1 button’s code is it not? Dont you think using these to track state would make the most sense? I do.

binary_sensor:
  - platform: remote_receiver
    name: Garage
    raw:
      code: [346,-692,346,-692,346,-692,346,-692,346,-346,692,-692,346,-692,346,-692,
        346,-692,346,-692,346,-346,692,-692,346]

Is there more to your yaml that you’ve left out? Not including board setup, wifi, api, etc. Did you leave out any other sensors or config?

Also, why in the world are using the same gpio pin for the transmitter and receiver? Thats going to make even less reliable at tracking states. Not a very good idea there.

remote_transmitter:
  - pin: 
      number: 5 # This is GDO0
      allow_other_uses: true
    carrier_duty_percent: 100%

remote_receiver:
  - pin: 
      number: 5 # This is GDO0
      allow_other_uses: true
    dump:
      - raw