Created
July 14, 2021 10:16
-
-
Save grischard/831e3c0d083527aa7b7ba2e12ef7520b to your computer and use it in GitHub Desktop.
Hob2Hood for esphome with four relays. Works with esphome 1.16.0, needs updating for more recent versions. Three push buttons: light, fan up, fan down. Four relays: light, fan 1, fan 2, fan 3.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
substitutions: | |
device: smarthood | |
name: Smart Hood | |
reboot_timeout: 1h | |
update_interval: 60s | |
delayed_on_off: 20ms | |
pin_relay_lamp: D0 | |
pin_relay_fan1: D3 | |
pin_relay_fan2: D2 | |
pin_relay_fan3: D1 | |
pin_button_lamp: D4 | |
pin_button_up: D5 | |
pin_button_down: D6 | |
pin_IR: D7 | |
# D8 empty, output only, and locks on start if I connect it to a relay (pulled high) | |
esphome: | |
name: ${device} | |
platform: ESP8266 | |
board: nodemcuv2 | |
# Boilerplate: wifi, api, ota, web server, text sensors | |
<<: !include common/common.yaml | |
# Boilerplate: logging | |
<<: !include common/logger.yaml | |
# Boilerplate: wifi signal, uptime | |
<<: !include common/sensors.yaml | |
remote_receiver: | |
pin: | |
number: ${pin_IR} | |
# Don't invert, despite what the log says | |
mode: INPUT_PULLUP | |
# dump: all | |
switch: | |
- platform: gpio | |
id: fan_low_relay | |
pin: | |
number: ${pin_relay_fan1} | |
inverted: yes | |
restore_mode: ALWAYS_OFF | |
interlock: &interlock_group [fan_low, fan_med, fan_high] | |
interlock_wait_time: 100ms | |
- platform: gpio | |
id: fan_med_relay | |
pin: | |
number: ${pin_relay_fan2} | |
inverted: yes | |
restore_mode: ALWAYS_OFF | |
interlock: *interlock_group | |
interlock_wait_time: 100ms | |
- platform: gpio | |
id: fan_high_relay | |
pin: | |
number: ${pin_relay_fan3} | |
inverted: yes | |
restore_mode: ALWAYS_OFF | |
interlock: *interlock_group | |
interlock_wait_time: 100ms | |
- platform: gpio | |
id: relay_light | |
name: Light | |
restore_mode: ALWAYS_OFF | |
pin: | |
inverted: yes | |
number: ${pin_relay_lamp} | |
- platform: template | |
id: fan_off | |
lambda: |- | |
if (id(fan_hood).state){ | |
return false; | |
} else { | |
return true; | |
} | |
turn_on_action: | |
- fan.turn_off: | |
id: fan_hood | |
- platform: template | |
id: fan_low | |
turn_on_action: | |
- fan.turn_on: | |
id: fan_hood | |
speed: LOW | |
- platform: template | |
id: fan_med | |
turn_on_action: | |
- fan.turn_on: | |
id: fan_hood | |
speed: MEDIUM | |
- platform: template | |
id: fan_high | |
turn_on_action: | |
- fan.turn_on: | |
id: fan_hood | |
speed: HIGH | |
binary_sensor: | |
- !include common/binary_sensor/status.yaml | |
- platform: gpio | |
pin: | |
number: ${pin_button_up} | |
mode: INPUT_PULLUP | |
inverted: yes | |
id: button_up | |
filters: | |
- delayed_on_off: ${delayed_on_off} | |
on_press: | |
then: | |
- lambda: |- | |
if (id(fan_hood).state) { | |
if (id(fan_hood).speed == 0) { | |
id(fan_med).turn_on(); | |
ESP_LOGD("main", "Fan set to Medium"); | |
} else { | |
if (id(fan_hood).speed == 1){ | |
id(fan_high).turn_on(); | |
ESP_LOGD("main", "Fan set to High"); | |
} else { | |
ESP_LOGD("main", "Captain, I'm giving her all she's got!"); | |
} | |
} | |
} else { | |
id(fan_low).turn_on(); | |
ESP_LOGD("main", "Fan set to Low"); | |
} | |
- platform: gpio | |
pin: | |
number: ${pin_button_down} | |
mode: INPUT_PULLUP | |
inverted: yes | |
filters: | |
- delayed_on_off: ${delayed_on_off} | |
id: button_down | |
on_press: | |
then: | |
- lambda: |- | |
if (id(fan_hood).state) { | |
if (id(fan_hood).speed == 0) { | |
id(fan_off).turn_on(); | |
ESP_LOGD("main", "Fan set to Off"); | |
} else { | |
if (id(fan_hood).speed == 1){ | |
id(fan_low).turn_on(); | |
ESP_LOGD("main", "Fan set to Low"); | |
} else { | |
id(fan_med).turn_on(); | |
ESP_LOGD("main", "Fan set to Medium"); | |
} | |
} | |
} else { | |
ESP_LOGD("main", "He's dead, Jim"); | |
} | |
- platform: gpio | |
pin: | |
number: ${pin_button_lamp} | |
mode: INPUT_PULLUP | |
inverted: yes | |
id: button_light | |
filters: | |
- delayed_on_off: ${delayed_on_off} | |
on_press: | |
then: | |
- switch.toggle: relay_light | |
# IR codes from https://github.com/JameZUK/hob2hood-RAW-IR-Codes | |
- platform: remote_receiver | |
id: Hob2Hood_Speed_Off | |
raw: | |
code: [-720, 1468, -722, 1470, -2114, 1472, -722, 1470, -1416, 2218, -724, 1470, -724, 720, -698] | |
on_press: | |
then: | |
- fan.turn_off: | |
id: fan_hood | |
- platform: remote_receiver | |
id: Hob2Hood_Speed_Low | |
raw: | |
code: [-1416, 1494, -722, 1570, -1974, 1510, -722, 1468, -726, 718, -724, 1468, -724, 2216, -696] | |
on_press: | |
then: | |
- fan.turn_on: | |
id: fan_hood | |
speed: LOW | |
- platform: remote_receiver | |
id: Hob2Hood_Speed_Medium | |
raw: | |
code: [-1440, 1472, -724, 2936, -752, 2190, -3530, 2224, -2114] | |
on_press: | |
then: | |
- fan.turn_on: | |
id: fan_hood | |
speed: MEDIUM | |
- platform: remote_receiver | |
id: Hob2Hood_Speed_High | |
raw: | |
code: [-696, 2240, -2784, 2968, -2116, 750, -724, 2216, -2114] | |
on_press: | |
then: | |
- fan.turn_on: | |
id: fan_hood | |
speed: HIGH | |
- platform: remote_receiver | |
id: Hob2Hood_Speed_Turbo | |
raw: | |
code: [-1416, 2244, -1418, 722, -1418, 2216, -1418, 1470, -724, 2216, -722, 722, -1392] | |
on_press: | |
then: | |
- fan.turn_on: | |
id: fan_hood | |
speed: HIGH | |
- platform: remote_receiver | |
id: Hob2Hood_Light_On | |
raw: | |
#code: [-654, 1525, -626, 802, -1330, 802, -626, 1524, -627, 774, -1354, 2975, -626, 800, -627, 800, -1327] | |
code: [-718, 1472, -720, 726, -1388, 752, -718, 1472, -694, 750, -1390, 2994, -720, 724, -720, 726, -1386] | |
on_press: | |
then: | |
- switch.turn_on: | |
id: relay_light | |
- platform: remote_receiver | |
id: Hob2Hood_Light_Off | |
raw: | |
code: [-684, 1488, -658, 778, -684, 758, -686, 2278, -660, 788, -628, 1532, -688, 1504, -686, 786, -658] | |
on_press: | |
then: | |
- switch.turn_off: | |
id: relay_light | |
output: | |
- platform: template | |
id: fanoutput | |
type: float | |
write_action: | |
- if: | |
condition: | |
lambda: return ((state < 0.33)); | |
then: | |
# action for off | |
- switch.turn_off: fan_low_relay | |
- switch.turn_off: fan_med_relay | |
- switch.turn_off: fan_high_relay | |
- if: | |
condition: | |
lambda: return ((state > 0) && (state < .34)); | |
then: | |
# action for low | |
- switch.turn_off: fan_med_relay | |
- switch.turn_off: fan_high_relay | |
- switch.turn_on: fan_low_relay | |
- if: | |
condition: | |
lambda: return ((state > .34) && (state < .7)); | |
then: | |
# action for medium | |
- switch.turn_off: fan_low_relay | |
- switch.turn_off: fan_high_relay | |
- switch.turn_on: fan_med_relay | |
- if: | |
condition: | |
lambda: return ((state > 0.99)); | |
then: | |
# action for high | |
- switch.turn_off: fan_low_relay | |
- switch.turn_off: fan_med_relay | |
- switch.turn_on: fan_high_relay | |
fan: | |
- platform: speed | |
output: fanoutput | |
id: fan_hood | |
name: "Fan" |
Hi Maarten! Glad it looks useful to you. The HX1838 looks a lot fancier than what I used, which was a simple Vishay TSOP38438. The receiver on your kit, the VS1838, didn't give me good results with bright lights, which you tend to have in a kitchen. As always, your mileage may vary.
https://www.analysir.com/blog/2014/12/08/infrared-receiver-showdown-tsop34438-vs-vs1838b-winner-revealed/ has a comparison. The TSOP38438 is a successor of the TSOP34438 in that test, but whatever you can get should work well.
Hi, thanks for the response!
I ordered a TSOP38438 at a local supplier. I will fork the code to make it sensor only, my actual hood is already controlled over wifi.
Oh cool! Were you able to reverse engineer the wifi protocol it uses?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, thanks for the nice config!
One small question: which kind of IR receiver are you using with ESPHOME? I've a HX1838 laying around here, would that be an option?
Thanks in advance!