I wanted to share my project. I’m new to Home Assistant and this is my first real project. I decided to make my living room Minka-Aire Fan controllable from home assistant. I wanted to use a Wemos D1 mini and took the remote control for the fan. I also found a very helpful GitHub project by Aaron Nielsen where he showed how to wire each button to a relay. I’m by no means an expert here but hopefully someone can also benefit from this too.
The Minka-Aire fan remote control board uses 12V and the Wemos D1 mini and relay module uses 5V power so I found a power module with both 5V and 12V power. The fan remote used a 12V battery so I just soldered wires to the board and connected them to the power module. I wasn’t entirely sure the best way to wire the power directly to the Wemos D1 mini and my understanding is that if you by-pass the usb it also by-passes some of the power safety modules. So I found a right angle USB to dupont cable and after a slight cable modification, I was able to wire that directly to the power module. I connected the relay directly to the 5v power rather than draw from the D1 Mini to keep the D1 mini stable.
The power module wasn’t the best quality and I had to test a few of them using a multi-meter before I found one that was working correctly. The first 2 I tried were pushing out 12v on all outputs but I found one that was stable and working correctly. Using the wiring guide from Aaron Nielsen’s github, I soldered wires directly to the fan remote board and connected them to the relay. Technically, the remote has 7 different physical buttons but the fan remote’s light on and off buttons basically just toggle the light vs on and off. I wired up and connected the 7 buttons (High,Med,Low,Off,Change Rotation,Up Light, Down Light) to the relay.
After reading a few guides on ESPHome, I learned a few important things. Since the remote only needs one button to be pressed at a time, I found that interlocking could help make sure that this doesn’t happen. Since I don’t want to buttons to be pressed when the D1 mini turns on I turned on inverted for each of the switches. I also had to add a bit of a delay to each button and since the light buttons on the fan remote act like more of a toggle, I have one setup as the on and off and the 2nd setup with a longer delay that is able to dim the light when pressed.
After the wiring and coding was done, all that was left was to build a 3d printed box to house the power module, D1 min, fan remote board and 8 port relay. I had to create it in a few different pieces that connect together to fit it all but it really worked out well. I did break the lid and I’m working on printing another but nothing some electrical tape couldn’t fix.
ESPHome Code
esphome:
name: familyroomfan
platform: ESP8266
board: d1_mini
# Enable Home Assistant API
switch:
- platform: gpio
pin: 5 #D1
id: relay1
inverted: yes
interlock: &interlock_group [relay1, relay2, relay3, relay4, relay5, relay6, relay7, relay8]
- platform: gpio
pin: 4 #D2
id: relay2
inverted: yes
interlock: *interlock_group
- platform: gpio
pin: 2 #D4
id: relay3
inverted: yes
interlock: *interlock_group
- platform: gpio
pin: 16 #D0
id: relay4
inverted: yes
interlock: *interlock_group
- platform: gpio
pin: 14 #D5
id: relay5
inverted: yes
interlock: *interlock_group
- platform: gpio
pin: 12 #D6
id: relay6
inverted: yes
interlock: *interlock_group
- platform: gpio
pin: 13 #D7
id: relay7
inverted: yes
interlock: *interlock_group
- platform: gpio
pin: 15 #D8
id: relay8
inverted: yes
interlock: *interlock_group
- platform: template
name: "Toggle Fan Light"
id: FRF_ToggleFanLight
icon: "mdi:lightbulb"
turn_on_action:
- switch.turn_on: relay1
- delay: 90ms
- switch.turn_off: relay1
- switch.template.publish:
id: FRF_ToggleFanLight
state: ON
turn_off_action:
- switch.turn_on: relay1
- delay: 90ms
- switch.turn_off: relay1
- switch.template.publish:
id: FRF_ToggleFanLight
state: OFF
- platform: template
name: "Dim Fan Light"
icon: "mdi:lightbulb-on"
turn_on_action:
- switch.turn_on: relay2
- delay: 1600ms
- switch.turn_off: relay2
- platform: template
name: "Fan On High"
id: FRF_FanOnHigh
icon: "mdi:gauge-full"
turn_on_action:
- switch.turn_on: relay6
- delay: 90ms
- switch.turn_off: relay6
- switch.template.publish:
id: FRF_FanOnHigh
state: ON
- switch.template.publish:
id: FRF_FanOnMedium
state: OFF
- switch.template.publish:
id: FRF_FanOnLow
state: OFF
- switch.template.publish:
id: FRF_FanOff
state: ON
turn_off_action:
- switch.toggle: FRF_FanOff
- platform: template
name: "Fan On Medium"
icon: "mdi:gauge"
id: FRF_FanOnMedium
turn_on_action:
- switch.turn_on: relay4
- delay: 90ms
- switch.turn_off: relay4
- switch.template.publish:
id: FRF_FanOnHigh
state: OFF
- switch.template.publish:
id: FRF_FanOnMedium
state: ON
- switch.template.publish:
id: FRF_FanOnLow
state: OFF
- switch.template.publish:
id: FRF_FanOff
state: ON
turn_off_action:
- switch.toggle: FRF_FanOff
- platform: template
name: "Fan On Low"
icon: "mdi:gauge-low"
id: FRF_FanOnLow
turn_on_action:
- switch.turn_on: relay5
- delay: 90ms
- switch.turn_off: relay5
- switch.template.publish:
id: FRF_FanOnHigh
state: OFF
- switch.template.publish:
id: FRF_FanOnMedium
state: OFF
- switch.template.publish:
id: FRF_FanOnLow
state: ON
- switch.template.publish:
id: FRF_FanOff
state: ON
turn_off_action:
- switch.toggle: FRF_FanOff
- platform: template
name: "Fan Off"
icon: "mdi:fan-off"
id: FRF_FanOff
turn_on_action:
- switch.turn_on: relay3
- delay: 120ms
- switch.turn_off: relay3
- switch.template.publish:
id: FRF_FanOnHigh
state: OFF
- switch.template.publish:
id: FRF_FanOnMedium
state: OFF
- switch.template.publish:
id: FRF_FanOnLow
state: OFF
- switch.template.publish:
id: FRF_FanOff
state: OFF
turn_off_action:
- switch.turn_on: relay3
- delay: 120ms
- switch.turn_off: relay3
- switch.template.publish:
id: FRF_FanOnHigh
state: OFF
- switch.template.publish:
id: FRF_FanOnMedium
state: OFF
- switch.template.publish:
id: FRF_FanOnLow
state: OFF
- switch.template.publish:
id: FRF_FanOff
state: OFF
- platform: template
name: "Fan Change Rotation"
icon: "mdi:rotate-3d"
turn_on_action:
- switch.turn_on: relay7
- delay: 90ms
- switch.turn_off: relay7
binary_sensor:
- platform: status
name: "Family Room ESPHome Status"
List of Items:
- Minka-Aire Remote Control
- WeMos D1 Mini
- ELEGOO 8 Channel DC 5V Relay Module
- DC-DC 12V to 3.3V 5V Power Module 3.3V 5V 12V Multi Output Voltage Conversion
- USB Header to Micro USB Dupont
Images
- Power Module
- Relay Wiring
- 3D Module of Enclosure
- Inside of Enclosure
- Full Assembly (I sort of broke the lid and fixed it up with some tape)
- Home Assistant Controlls
I’ve really enjoyed working on this project and its been a great way to really get to explore the power of Home Assistant and ESPHome. I probably should have kept better track of sources so if I missed linking something, please let me know. Thanks!
Edit:
Updated ESPHome code to handle On/Off status handling for a more logical experience with HomeAssistant.