I have been trying to get this right and looking for example / code for a while…so I am hoping I didnt miss something!
The boiler plate is left off in the below. Here is the project:
I have removed the control board from multiple Vornado fans; they all work with some kind of triac that when brought low at 5v opens a 110vac line to the fan at various speeds and for oscillation. I cut the trace for the 5v generator, then soldered in an ESP32 and put in my own 5v (using an old usb charger to the esp32). I wanted to use this janky setup to make sure it worked before I put in an m5 stamp for size.
Each of the switches works fine. The fan works great this way. But I want to make it a “real fan” in HA, but I cannot for the life of me get the oscillation to work in HA to the device. I repeat everything works great from the web ui on the device. Just not in HA. So I am focusing on the fan: template here. There appears to be no id(myfan).oscilate_off() or the like as there is for the switches and also I cannot figure out how to make the swing turn off when the fan is off. So the oscillation state is never the same in HA as on the device…
Given how every single fan I have opened works the same way - ac lines for windings that represent speed it seems like we almost need another sub-type of fan where each switch is a speed. So you would feed in a config of GPIOs for each speed and swing. I have opened up 14 fans each of them works exactly the same way, so if you were to take a 4 chan relay board you could use interlocking to automate it and it would be the same config.
Maybe I am missing something fundamental here…but I appreciate the help.
BTW speed step works perfectly!
switch:
- platform: gpio
name: High
id: high
interlock: &interlock_group [high, medlow, medium, low]
pin:
number: 48
inverted: true
mode:
output: true
open_drain: true
- platform: gpio
name: Medium Low
id: medlow
interlock: *interlock_group
pin:
number: 47
inverted: true
mode:
output: true
open_drain: true
- platform: gpio
name: Swing
id: swing
pin:
number: 46
inverted: true
mode:
output: true
open_drain: true
- platform: gpio
name: Medium
id: medium
interlock: *interlock_group
pin:
number: 45
inverted: true
mode:
output: true
open_drain: true
- platform: gpio
name: Low
id: low
interlock: *interlock_group
pin:
number: 21
inverted: true
mode:
output: true
open_drain: true
fan:
- platform: template
name: "Virtual Fan"
id: thefan
has_oscillating: true
speed_count: 4
restore_mode: RESTORE_DEFAULT_OFF
on_oscillating_set:
- lambda: |-
if (id(thefan).oscillating) {
id(swing).turn_on();
} else {
id(swing).turn_off();
}
on_speed_set:
- lambda: |-
if (id(thefan).speed == 1) {
id(low).turn_on();
} else if (id(thefan).speed == 2) {
id(medlow).turn_on();
} else if (id(thefan).speed == 3) {
id(medium).turn_on();
} else if (id(thefan).speed == 4) {
id(high).turn_on();
} else {
id(high).turn_on();
}
on_turn_on:
- lambda: |-
id(low).turn_on();
on_turn_off:
- lambda: |-
id(swing).turn_off();
id(low).turn_off();
id(medlow).turn_off();
id(medium).turn_off();
id(high).turn_off();