Here’s my contribution to this great community.
An ESPhome based IR Blaster that can handle several protocols.
There is also an option to record IR codes from unknown devices or remotes.
To test this go to Developers tools - services
Select ESPHome: ir_blaster_send_ir
Filled the data and call service.
# IR Blaster
# by AA van Zoelen
#
# Version: 1.1
# Date : 23 Aug 2022
#
# Description
# ===========
# Protocol : String in UPPERCASE
# Code : Some protocols name this also data, address, wand_id, rc_code1
# Command : Some protocols name this also nbits, magnitude, rc_code2
# Repeat : Optionally set the code to be repeated a number of times. Otherwise use 1.
#
# Implemented protocols
# - COOLIX
# - DISH
# - JVC
# - LG
# - MAGIQUEST
# - NEC
# - PANASONIC
# - PIONEER (repeat 2 added)
# - PRONTO
# - RC5
# - RC6
# - SAMSUNG
# - SAMSUNG36
# - SONY
# - TOSHIBA_AC
#
# Details
# -------
# MCU used is a Wemos D1 mini
#
# Minimal components
# IR receiver such as TSOP38238 - IR receiver
# NPN transistor (e.g. BC549C, 2n2222)
# IR LED
#
esphome:
name: "ir-blaster"
platform: ESP8266
board: nodemcuv2
# Enable logging
logger:
# Enable Home Assistant API
api:
services:
- service: send_ir
variables:
protocol: string
code: string
command: string
repeats: string
then:
- lambda: 'ESP_LOGD("main", "Protocol: %s - Code: %s - Command: %s", protocol.c_str(), code.c_str(), command.c_str() ); '
- if:
condition: # --=[ *** COOLIX *** ]=--
lambda: 'return protocol == "COOLIX";'
then:
- logger.log: "Sending COOLIX data...!"
- remote_transmitter.transmit_coolix:
data: !lambda |-
int i;
sscanf( code.c_str(), "%x", &i );
return i;
- if:
condition: # --=[ *** DISH *** ]=--
lambda: 'return protocol == "DISH";'
then:
- logger.log: "Sending DISH data...!"
- remote_transmitter.transmit_dish:
address: !lambda |-
return std::stoi( code );
command: !lambda |-
return std::stoi( command );
- if:
condition: # --=[ *** JVC *** ]=--
lambda: 'return protocol == "JVC";'
then:
- logger.log: "Sending JVC data...!"
- remote_transmitter.transmit_jvc:
data: !lambda |-
int i;
sscanf( code.c_str(), "%x", &i );
return i;
- if:
condition: # --=[ *** LG *** ]=--
lambda: 'return protocol == "LG";'
then:
- logger.log: "Sending LG data...!"
- remote_transmitter.transmit_lg:
data: !lambda |-
int i;
sscanf(code.c_str(), "%x", &i );
return i;
nbits: !lambda |-
return std::stoi( command );
- if:
condition: # --=[ *** MAGIQUEST *** ]=--
lambda: 'return protocol == "MAGIQUEST";'
then:
- logger.log: "Sending MAGIQUEST data...!"
- remote_transmitter.transmit_magiquest:
wand_id: !lambda |-
int i;
sscanf( code.c_str(), "%x", &i );
return i;
magnitude: !lambda |-
int i;
sscanf( command.c_str(), "%x", &i );
return i;
- if:
condition: # --=[ *** NEC *** ]=--
lambda: 'return protocol == "NEC";'
then:
- logger.log: "Sending NEC data...!"
- remote_transmitter.transmit_nec:
address: !lambda |-
int i;
sscanf( code.c_str(), "%x", &i );
return i;
command: !lambda |-
int i;
sscanf( command.c_str(), "%x", &i );
return i;
- if:
condition: # --=[ *** PANASONIC *** ]=--
lambda: 'return protocol == "PANASONIC";'
then:
- logger.log: "Sending PANASONIC data...!"
- remote_transmitter.transmit_panasonic:
address: !lambda |-
int i;
sscanf( code.c_str(), "%x", &i );
return i;
command: !lambda |-
int i;
sscanf( command.c_str(), "%x", &i );
return i;
- if:
condition: # --=[ *** PIONEER *** ]=--
lambda: 'return protocol == "PIONEER";'
then:
- logger.log: "Sending PIONEER data...!"
- remote_transmitter.transmit_pioneer:
rc_code_1: !lambda |-
int i;
sscanf( code.c_str(), "%x", &i );
return i;
rc_code_2: !lambda |-
int i;
sscanf( command.c_str(), "%x", &i );
return i;
repeat:
times: !lambda |-
return std::stoi( repeats );
- if:
condition: # --=[ *** PRONTO *** ]=--
lambda: 'return protocol == "PRONTO";'
then:
- logger.log: "Sending PRONTO data...!"
- remote_transmitter.transmit_pronto:
data: !lambda |-
return code.c_str();
- if:
condition: # --=[ *** RC5 *** ]=--
lambda: 'return protocol == "RC5";'
then:
- logger.log: "Sending RC5 data...!"
- remote_transmitter.transmit_rc5:
address: !lambda |-
int i;
sscanf( code.c_str(), "%x", &i );
return i;
command: !lambda |-
int i;
sscanf( command.c_str(), "%x", &i );
return i;
- if:
condition: # --=[ *** RC6 *** ]=--
lambda: 'return protocol == "RC6";'
then:
- logger.log: "Sending RC6 data...!"
- remote_transmitter.transmit_rc6:
address: !lambda |-
int i;
sscanf( code.c_str(), "%x", &i );
return i;
command: !lambda |-
int i;
sscanf( command.c_str(), "%x", &i );
return i;
- if:
condition: # --=[ *** SAMSUNG *** ]=--
lambda: 'return protocol == "SAMSUNG";'
then:
- logger.log: "Sending SAMSUNG data...!"
- remote_transmitter.transmit_samsung:
data: !lambda |-
int i;
sscanf( code.c_str(), "%x", &i );
return i;
nbits: !lambda |-
return std::stoi( command );
- if:
condition: # --=[ *** SAMSUNG36 *** ]=--
lambda: 'return protocol == "SAMSUNG36";'
then:
- logger.log: "Sending SAMSUNG36 data...!"
- remote_transmitter.transmit_samsung36:
address: !lambda |-
int i;
sscanf( code.c_str(), "%x", &i );
return i;
command: !lambda |-
int i;
sscanf( command.c_str(), "%x", &i );
return i;
- if:
condition: # --=[ *** SONY *** ]=--
lambda: 'return protocol == "SONY";'
then:
- logger.log: "Sending SONY data...!"
- remote_transmitter.transmit_sony:
data: !lambda |-
int i;
sscanf( code.c_str(), "%x", &i );
return i;
nbits: !lambda |-
return std::stoi( command );
- if:
condition: # --=[ *** TOSHIBA AC *** ]=--
lambda: 'return protocol == "TOSHIBA_AC";'
then:
- logger.log: "Sending TOSHIBA data...!"
- remote_transmitter.transmit_toshiba_ac:
rc_code_1: !lambda |-
int i;
sscanf( code.c_str(), "%x", &i );
return i;
rc_code_2: !lambda |-
int i;
sscanf( command.c_str(), "%x", &i );
return i;
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: !secret backdoor_ssid
password: !secret backdoor_password
captive_portal:
remote_receiver:
pin:
number: D5
inverted: true
dump: all
remote_transmitter:
pin: D7
carrier_duty_percent: 50%