Based on the code for this project (Arduino-Hob2Hood/Hob2Hood.ino at dd49e276af1daf824b515881fa42f53bf2a14624 · tuxedo0801/Arduino-Hob2Hood · GitHub), I made my own code for ESPHOME. I am not experienced in this matter yet and ask for advice. How can I better implement work with RAW codes? Is it possible not to list them, but to transfer them as LONG?
# IR commands from AEG/Electrolux hob2hood device https://github.com/tuxedo0801/Arduino-Hob2Hood/blob/dd49e276af1daf824b515881fa42f53bf2a14624/Hob2Hood.ino
#const long IRCMD_VENT_1 = 0xE3C01BE2; // Hob2hood On (level 1) raw code = {1538, 1342, 794, 1340, 2290, 1340, 790, 1346, 788, 652, 788, 1346, 794, 2040, 790}
#const long IRCMD_VENT_2 = 0xD051C301; // Hob2hood level 2 raw code = {1542, 1340, 790, 2738, 816, 2014, 3788, 2026, 2292}
#const long IRCMD_VENT_3 = 0xC22FFFD7; // Hob2hood level 3 raw code = {790, 2042, 3036, 2730, 2290, 644, 790, 2042, 2286}
#const long IRCMD_VENT_4 = 0xB9121B29; // Hob2hood level 4 raw code = {1540, 2036, 1540, 650, 1540, 2034, 1542, 1340, 790, 2042, 794, 646, 1540}
#const long IRCMD_VENT_OFF = 0x55303A3;// Hob2hood off raw code = {790, 1344, 786, 1350, 2290, 1340, 794, 1344, 1536, 2040, 794, 1344, 792, 650, 788}
#const long IRCMD_LIGHT_ON = 0xE208293C;// Light on (Hood on) raw code = {786, 1348, 790, 652, 1538, 648, 790, 1344, 784, 656, 1540, 2734, 790, 652, 790, 650, 1538}
#const long IRCMD_LIGHT_OFF = 0x24ACF947;// Light off (Automatic after 2min) raw code = {762, 1424, 770, 674, 764, 676, 760, 2172, 760, 680, 766, 1420, 766, 1420, 760, 682, 760}
esphome:
name: new8266
friendly_name: new8266
esp8266:
board: esp01_1m
# Enable logging
logger:
#level: VERBOSE
#tx_buffer_size: 1024 # Log large Pronto Codes
# Enable Home Assistant API
api:
encryption:
key: "J9y7B9VfI+wy4qp6B5I2fj1YJVwilFeMAVMwmP2A1es="
ota:
- platform: esphome
password: "4307b9782280616940a7ff1a2e91b43f"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "New8266 Fallback Hotspot"
password: "lpwy6tTR7qQD"
captive_portal:
# Sync time with Home Assistant.
time:
- platform: homeassistant
id: homeassistant_time
# Signal WiFi
sensor:
- platform: wifi_signal
name: "WiFi"
update_interval: 30s
- platform: uptime
name: "Uptime"
# WiFi IP
text_sensor:
- platform: wifi_info
ip_address:
name: "IP"
# WiFi LED Status (internal: True — не публикует в HA)
light:
- platform: status_led
name: "Switch state"
pin: GPIO2
internal: True
# IRDA
remote_receiver:
pin:
number: GPIO05
inverted: True
mode: INPUT_PULLUP
#dump: raw
buffer_size: 1kb
idle: 25ms
binary_sensor:
- platform: gpio
name: "Hood Button Level 1"
pin:
number: GPIO1
inverted: True
mode:
INPUT_PULLUP
filters:
- delayed_on: 10ms
id: H2H_Button_FanSpeed1
on_press:
then:
- if:
condition:
- switch.is_off: relay1
then:
- switch.turn_on: relay1
else:
- switch.turn_off: relay1
- platform: gpio
name: "Hood Button Level 2"
pin:
number: GPIO4
inverted: True
mode:
INPUT_PULLUP
filters:
- delayed_on: 10ms
id: H2H_Button_FanSpeed2
on_press:
then:
- if:
condition:
- switch.is_off: relay2
then:
- switch.turn_on: relay2
else:
- switch.turn_off: relay2
- platform: gpio
name: "Hood Button Level 3"
pin:
number: GPIO0
inverted: True
mode:
INPUT_PULLUP
filters:
- delayed_on: 10ms
id: H2H_Button_FanSpeed3
on_press:
then:
- if:
condition:
- switch.is_off: relay3
then:
- switch.turn_on: relay3
else:
- switch.turn_off: relay3
- platform: gpio
name: "Hood Button Light on/off"
pin:
number: GPIO3
inverted: True
mode: INPUT_PULLUP
filters:
- delayed_on: 10ms
id: H2H_Button_Light
on_press:
then:
- if:
condition:
- switch.is_off: relay4
then:
- switch.turn_on: relay4
else:
- switch.turn_off: relay4
- platform: remote_receiver
# const long IRCMD_VENT_1 = 0xE3C01BE2
# Hob2hood On (level 1) raw code = {1538, 1342, 794, 1340, 2290, 1340, 790, 1346, 788, 652, 788, 1346, 794, 2040, 790}
name: "Hob send: Level 1"
raw:
code:
- 1538
- -1342
- 794
- -1340
- 2290
- -1340
- 790
- -1346
- 788
- -652
- 788
- -1346
- 794
- -2040
- 790
filters:
- delayed_off: 200ms
on_press:
- switch.turn_on: relay1
- switch.turn_on: relay4
- platform: remote_receiver
# const long IRCMD_VENT_2 = 0xD051C301
# Hob2hood level 2 raw code = {1542, 1340, 790, 2738, 816, 2014, 3788, 2026, 2292}
name: "Hob send: Level 2"
raw:
code:
- 1542
- -1340
- 790
- -2738
- 816
- -2014
- 3788
- -2026
- 2292
filters:
- delayed_off: 200ms
on_press:
- switch.turn_on: relay2
- switch.turn_on: relay4
- platform: remote_receiver
# const long IRCMD_VENT_3 = 0xC22FFFD7
# Hob2hood level 3 raw code = {790, 2042, 3036, 2730, 2290, 644, 790, 2042, 2286}
name: "Hob send: Level 3"
raw:
code:
- 790
- -2042
- 3036
- -2730
- 2290
- -644
- 790
- -2042
- 2286
filters:
- delayed_off: 200ms
on_press:
- switch.turn_on: relay3
- switch.turn_on: relay4
- platform: remote_receiver
# const long IRCMD_VENT_4 = 0xB9121B29
# Hob2hood level 4 raw code = {1540, 2036, 1540, 650, 1540, 2034, 1542, 1340, 790, 2042, 794, 646, 1540}
name: "Hob send: Level 4"
raw:
code:
- 1540
- -2036
- 1540
- -650
- 1540
- -2034
- 1542
- -1340
- 790
- -2042
- 794
- -646
- 1540
filters:
- delayed_off: 200ms
on_press:
- switch.turn_on: relay3
- switch.turn_on: relay4
- platform: remote_receiver
# const long IRCMD_LIGHT_ON = 0xE208293C
# Light on (Hood on) raw code = {786, 1348, 790, 652, 1538, 648, 790, 1344, 784, 656, 1540, 2734, 790, 652, 790, 650, 1538}
name: "Hob send: Light on"
raw:
code:
- 786
- -1348
- 790
- -652
- 1538
- -648
- 790
- -1344
- 784
- -656
- 1540
- -2734
- 790
- -652
- 790
- -650
- 1538
filters:
- delayed_off: 200ms
on_press:
- switch.turn_on: relay4
- platform: remote_receiver
# const long IRCMD_LIGHT_OFF = 0x24ACF947
# Light off (Automatic after 2min) raw code = {762, 1424, 770, 674, 764, 676, 760, 2172, 760, 680, 766, 1420, 766, 1420, 760, 682, 760}
name: "Hob send: Light off"
raw:
code:
- 762
- -1424
- 770
- -674
- 764
- -676
- 760
- -2172
- 760
- -680
- 766
- -1420
- 766
- -1420
- 760
- -682
- 760
filters:
- delayed_off: 200ms
on_press:
- switch.turn_off: relay4
- switch.turn_off: relay1
- switch.turn_off: relay2
- switch.turn_off: relay3
- platform: remote_receiver
#const long IRCMD_VENT_OFF = 0x55303A3
# Hob2hood off raw code = {790, 1344, 786, 1350, 2290, 1340, 794, 1344, 1536, 2040, 794, 1344, 792, 650, 788}
name: "Hob send: hood off"
raw:
code:
- 790
- -1344
- 786
- -1350
- 2290
- -1340
- 794
- -1344
- 1536
- -2040
- 794
- -1344
- 792
- -650
- 788
filters:
- delayed_off: 200ms
on_press:
- switch.turn_off: relay1
- switch.turn_off: relay2
- switch.turn_off: relay3
- switch.turn_off: relay4
# Switches
switch:
- platform: gpio
name: "Relay_FanSpeed1"
pin: GPIO14
inverted: False
id: relay1
on_turn_on:
- switch.turn_off: relay2
- switch.turn_off: relay3
- platform: gpio
name: "Relay_FanSpeed2"
pin: GPIO12
inverted: False
id: relay2
on_turn_on:
- switch.turn_off: relay1
- switch.turn_off: relay3
- platform: gpio
name: "Relay_FanSpeed3"
pin: GPIO13
inverted: False
id: relay3
on_turn_on:
- switch.turn_off: relay1
- switch.turn_off: relay2
- platform: gpio
name: "Relay_Light"
pin: GPIO15
inverted: False
id: relay4
on_turn_on:
- switch.turn_on: relay4
on_turn_off:
- switch.turn_off: relay4