Well done.
I thought I’d done it the hard way
Enjoy recording your remote codes
Edit:
Just as I hit submit, I realised there’s a better approach to sending the codes… They should be buttons rather than the switches I’ve been using.
The toggles never made much sense, but they did work OK.
Better version:
esphome:
name: irblaster
friendly_name: IR_Blaster
bk72xx:
board: cb3s # https://docs.libretiny.eu/boards/cb3s/
#bk72xx:
# board: generic-bk7231n-qfn32-tuya
# <<: !include .common.yaml
logger: # Enable logging. https://esphome.io/components/logger.html
level: INFO # NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
api: # Enable Home Assistant API.
encryption:
key: !secret api_encryption_key
ota:
password: !secret ota_password
safe_mode: True
wifi: # WiFi connection details. Without domain:, defaults to .local. https://esphome.io/components/wifi.html
ssid: !secret wifi_ssid
password: !secret wifi_password
domain: .home
ap: # Enable fallback hotspot (captive portal) in case wifi connection fails
ssid: "${friendly_name} Fallback"
password: !secret fallback_password
captive_portal:
# Enable web server, browse to http://HOSTNAME or http://IP_Address. https://esphome.io/components/web_server.html
#web_server:
# port: 80
# include_internal: true # include intrnal entities
# local: true # Load everything locally rather than over the web
# # version: 1
sensor:
- platform: wifi_signal # Reports the WiFi signal strength in dB. https://esphome.io/components/sensor/wifi_signal.html
name: "WiFi Signal dB" # Uncomment to show signal DB in HA
id: wifi_signal_db
update_interval: 60s # Report signal every minute
entity_category: "diagnostic"
device_class: "signal_strength"
disabled_by_default: true # Shows entity in HA, but disabled by default
internal: true
- platform: copy # Reports the WiFi signal strength %
source_id: wifi_signal_db
name: "WiFi Signal"
filters:
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement: "%"
entity_category: "diagnostic"
device_class: "signal_strength"
disabled_by_default: true # Shows entity in HA, but disabled by default
# - platform: uptime
# id: uptime_seconds
# # update_interval: 10s
# # internal: true # Uncomment to leave internal and not send to HA
# name: "Uptime"
# entity_category: "diagnostic"
# disabled_by_default: true # Shows entity in HA, but disabled by default
# Sync time with Home Assistant
time:
- platform: homeassistant
id: ha_time
light:
- platform: status_led # Used as a status LED during errors, and status_light when OK. https://esphome.io/components/light/status_led
pin: P8
id: status_light
# name: Status LED # Uncomment to show in HA
icon: mdi:led-on
disabled_by_default: true # Shows entity in HA, but disabled by default
binary_sensor: # Button, https://esphome.io/components/binary_sensor/gpio
- platform: gpio
pin:
number: P6
inverted: true
mode:
input: true
pullup: true # Holds it high/off, otherwise it flutters on/off
name: "Button"
# icon: "mdi:button-pointer"
# internal: true # Hides button from HA
# disabled_by_default: true # Shows entity in HA, but disabled by default
on_press: # Switch LED on/off as a test
- light.turn_on: status_light
on_release:
- light.turn_off: status_light
# # Home Assistant sensor to store received remote command data
# text_sensor:
# - platform: template
# name: Learned Command
# icon: mdi:remote
# id: learned_command
remote_receiver:
pin:
number: P7
inverted: true
mode:
input: true
pullup: true
tolerance: 25
# dump: all
# dump: pronto
dump: raw
# dump: samsung
# on_samsung:
# - if:
# # If Samsung code is received
# condition:
# lambda: 'return id(remote_learn_switch).state;'
# then:
# - lambda: |-
# id(remote_learn_switch).publish_state(false);
# std::string log_output = "Samsung: Data = 0x" + esphome::format_hex((uint32_t)x.data) + ", nbits = " + esphome::to_string(x.nbits);
# id(learned_command).publish_state(log_output.c_str());
# - delay: 80ms
# - light.turn_on: status_light
# - delay: 500ms
# - light.turn_off: status_light
# # If Sony code is received
# on_sony:
# - if:
# condition:
# lambda: 'return id(remote_learn_switch).state;'
# then:
# - lambda: |-
# id(remote_learn_switch).publish_state(false);
# std::string log_output = "Sony: Data = 0x" + esphome::format_hex(x.data) + ", nbits = " + esphome::to_string(x.nbits);
# id(learned_command).publish_state(log_output.c_str());
# - delay: 80ms
# - light.turn_on: status_light
# - delay: 500ms
# - light.turn_off: status_light
remote_transmitter:
pin: P26
# Infrared remotes use a 50% carrier signal
carrier_duty_percent: 50%
button:
- platform: restart
id: reboot
name: "Reboot"
## Home Assistant controlled switch - to enable "learning mode"
# - platform: template
# name: Learn Command
# id: remote_learn_switch
# icon: mdi:remote
# optimistic: true
# IR codes to send from HA:
# FAN
- platform: template
name: Fan On/Speed
icon: mdi:fan
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_raw:
carrier_frequency: 38kHz
code: [1155, -438, 1250, -403, 437, -1250, 1291, -396, 1282, -406, 437, -1260, 428, -1250, 437, -1264, 434, -1240, 437, -1250, 1295, -393, 469, -7947, 1303, -406, 1291, -397, 468, -1219, 1281, -413, 1275, -406, 437, -1250, 441, -1250, 434, -1251, 437, -1263, 425, -1250, 1281, -410, 468, -7948, 1299, -406, 1282, -406, 447, -1240, 1250, -438, 1263, -424, 438, -1278, 409, -1254, 437, -1266, 418, -1250, 444, -1247, 1247, -438, 437, -7979, 1281, -428, 1250, -437, 438, -1263, 1237, -437, 1250, -438, 419, -1268, 407, -1281, 406, -1294, 425, -1250, 406, -1294, 1237, -438, 406]
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: Fan Off
icon: mdi:fan-off
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_raw:
carrier_frequency: 38kHz
code: [1164, -389, 1288, -399, 469, -1266, 1232, -414, 1275, -409, 441, -1274, 444, -1243, 437, -1267, 420, -1253, 434, -1267, 420, -1253, 1247, -7185, 1250, -441, 1246, -379, 472, -1274, 1266, -390, 1284, -403, 469, -1266, 421, -1253, 434, -1253, 437, -1246, 441, -1247, 439, -1264, 1240, -7165, 1271, -399, 1298, -390, 468, -1253, 1252, -417, 1265, -412, 462, -1250, 442, -1248, 435, -1253, 434, -1266, 421, -1256, 431, -1254, 1249, -7167, 1265, -444, 1243, -410, 481, -1233, 1287, -400, 1297, -390, 437, -1254, 434, -1266, 421, -1253, 434, -1249, 446, -1255, 440, -1240, 447]
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: Fan Osc
icon: mdi:fan-chevron-up
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_raw:
carrier_frequency: 38kHz
code: [1188, -403, 1298, -389, 437, -1250, 1291, -396, 1283, -403, 438, -1259, 428, -1249, 1281, -406, 437, -1256, 431, -1249, 438, -1259, 427, -8011, 1267, -406, 1284, -406, 434, -1250, 1280, -407, 1294, -392, 438, -1249, 437, -1288, 1243, -437, 406, -1291, 396, -1281, 406, -1281, 409, -8006, 1268, -437, 1249, -438, 406, -1290, 1240, -437, 1253, -434, 406, -1280, 406, -1281, 1259, -428, 406, -1280, 406, -1291, 409, -1268, 406, -8016, 1288, -410, 1249, -438, 406, -1293, 1237, -437, 1250, -437, 406, -1291, 396, -1280, 1263, -424, 406, -1281, 437, -1250, 416, -1270, 438, -7994, 1252, -437, 1259, -428, 406, -1280, 1260, -427, 1250, -437, 437, -1260, 427, -1249, 406, -1281, 404, -1293, 427, -1250, 437, -1263, 393, -8010, 1267, -437, 1255, -438, 431, -1250, 1249, -534, 1166, -424, 406, -1281, 406, -1294, 424, -1249, 438, -1259, 396, -1281, 437, -1250, 409, -8007, 1267, -437, 1250, -437, 406, -1291, 1239, -438, 1252, -437, 406, -1278, 406, -1295, 399, -1283, 396, -1281, 406, -1291, 396, -1281, 409, -8105, 1176, -462, 1218, -469, 375, -1286, 1246, -470, 1217, -438, 406, -1292, 396, -1282, 406, -1295, 393, -1281, 406, -1282, 416, -1272, 406]
- delay: 60ms
- light.turn_off: status_light
# Fish light
- platform: template
name: Fish light On/Off
icon: mdi:wall-sconce-flat-outline
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_raw:
carrier_frequency: 38kHz
code: [9956, -4437, 680, -1594, 687, -538, 650, -531, 656, -531, 656, -532, 659, -528, 656, -1593, 688, -531, 688, -531, 656, -1593, 688, -1624, 688, -1597, 684, -1593, 688, -1611, 701, -500, 656, -1628, 684, -1593, 688, -531, 656, -531, 657, -1593, 691, -1590, 688, -531, 656, -535, 653, -531, 687, -500, 656, -1706, 607, -1593, 689, -533, 653, -531, 657, -1595, 689, -1591, 688, -1632, 681]
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: Fish light 12:00
icon: mdi:update
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_raw:
carrier_frequency: 38kHz
code: [9777, -4469, 646, -1704, 577, -594, 594, -597, 628, -556, 625, -562, 625, -563, 635, -1681, 590, -594, 625, -575, 612, -1656, 625, -1708, 621, -1643, 622, -1711, 601, -1657, 676, -511, 625, -1688, 625, -585, 602, -563, 625, -1656, 647, -1665, 625, -1679, 603, -593, 625, -563, 594, -600, 660, -1646, 625, -1682, 600, -593, 594, -594, 656, -545, 643, -1682, 630, -1651, 599, -1688, 687]
- delay: 60ms
- light.turn_off: status_light
# Samsung TV
- platform: template
name: TV OK/Enter
# icon: mdi:check
icon: mdi:keyboard-return
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_samsung:
data: 0xE0E016E9
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: TV On/Off
icon: mdi:power
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_samsung:
data: 0xE0E040BF
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: TV Mute
icon: mdi:volume-mute
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_samsung:
data: 0xE0E0F00F
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: TV Menu
icon: mdi:menu
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_samsung:
data: 0xE0E058A7
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: TV Back
icon: mdi:undo
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_samsung:
data: 0xE0E01AE5
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: TV Up
icon: mdi:arrow-up-bold-outline
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_samsung:
data: 0xE0E006F9
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: TV Down
icon: mdi:arrow-down-bold-outline
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_samsung:
data: 0xE0E08679
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: TV Left
icon: mdi:arrow-left-bold-outline
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_samsung:
data: 0xE0E0A659
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: TV Right
icon: mdi:arrow-right-bold-outline
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_samsung:
data: 0xE0E046B9
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: TV Exit
icon: mdi:exit-to-app
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_samsung:
data: 0xE0E0B44B
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: TV Tools
icon: mdi:tools
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_samsung:
data: 0xE0E0D22D
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: TV Info
icon: mdi:information-variant
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_samsung:
data: 0xE0E0F807
- delay: 60ms
- light.turn_off: status_light
# PC
- platform: template
# yellow
name: Ambilight
icon: mdi:television-ambient-light
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_pronto:
data: "0000 0073 0000 0020 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0030 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0010 0010 0010 0010 0020 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0020 0020 0020 0010 0010 0010 0010 0020 0020 09DD"
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: Kodi Clean Library
icon: mdi:kodi
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_raw:
carrier_frequency: 38kHz
code: [2516, -921, 406, -468, 438, -437, 406, -937, 406, -906, 1315, -903, 406, -500, 406, -468, 406, -469, 406, -500, 406, -469, 406, -500, 405, -469, 406, -467, 408, -468, 438, -468, 844, -468, 437, -469, 406, -469, 406, -923, 388, -500, 407, -468, 409, -466, 437, -469, 843, -937, 406, -469, 406, -468, 844, -937, 437, -454, 858, -906, 406, -468, 406, -500, 406]
- delay: 60ms
- light.turn_off: status_light
- platform: template
# Guide
name: Kodi Refresh Library
icon: mdi:refresh
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_pronto:
data: "0000 0073 0000 0021 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0030 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0010 0010 0010 0010 0020 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0020 0010 0010 0020 0010 09CD"
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: Kodi Pause
icon: mdi:pause
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_pronto:
data: "0000 0073 0000 0022 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0030 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0010 0010 0010 0010 0010 09BD"
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: Kodi Back
icon: mdi:undo
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_pronto:
data: "0000 0073 0000 0021 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0030 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0020 0010 0010 09CF"
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: Kodi OK/Enter
# icon: mdi:check
icon: mdi:keyboard-return
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_pronto:
data: "0000 0071 0000 0020 0061 0021 0010 0011 0010 0011 0010 0021 0010 0021 0030 0021 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0020 0011 0010 0011 0010 0011 0010 0021 0010 0011 0020 0011 0010 0021 0020 0021 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0020 0021 0020 0011 0010 09EE"
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: Kodi Play
icon: mdi:play
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_pronto:
data: "0000 0073 0000 0021 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0030 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0010 0010 0010 0010 0020 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0020 0010 0010 0020 0010 09BC"
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: Kodi Up
icon: mdi:arrow-up-bold-outline
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_pronto:
data: "0000 0072 0000 0021 0061 0021 0010 0011 0010 0011 0010 0021 0010 0021 0030 0021 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0020 0011 0010 0011 0010 0011 0010 0021 0010 0011 0020 0011 0010 0021 0020 0021 0010 0011 0010 0011 0010 0011 0010 0011 0020 0011 0010 0011 0010 0011 0010 0021 0010 09D2"
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: Kodi Down
icon: mdi:arrow-down-bold-outline
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_pronto:
data: "0000 0072 0000 0021 0061 0021 0010 0011 0010 0011 0010 0021 0010 0021 0030 0021 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0020 0011 0010 0011 0010 0011 0010 0021 0010 0011 0020 0011 0010 0021 0020 0021 0010 0011 0010 0011 0010 0011 0010 0011 0020 0011 0010 0011 0010 0011 0010 0011 0010 09DE"
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: Kodi Left
icon: mdi:arrow-left-bold-outline
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_pronto:
data: "0000 0072 0000 0021 0061 0021 0010 0011 0010 0011 0010 0021 0010 0021 0030 0021 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0020 0011 0010 0011 0010 0011 0010 0021 0010 0011 0020 0011 0010 0021 0020 0021 0010 0011 0010 0011 0010 0011 0020 0021 0010 0011 0010 0011 0010 0011 0010 0011 0010 09CD"
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: Kodi Right
icon: mdi:arrow-right-bold-outline
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_pronto:
data: "0000 0072 0000 0020 0061 0021 0010 0011 0010 0011 0010 0021 0010 0021 0030 0021 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0010 0011 0020 0011 0010 0011 0010 0011 0010 0011 0010 0021 0020 0011 0010 0021 0020 0021 0010 0011 0010 0011 0010 0011 0020 0021 0010 0011 0010 0011 0010 0011 0020 09E3"
- delay: 60ms
- light.turn_off: status_light
- platform: template
name: Kodi Now Playing
icon: mdi:flip-to-back
on_press:
- light.turn_on: status_light
- remote_transmitter.transmit_pronto:
data: "0000 0073 0000 0021 0060 0020 0010 0010 0010 0010 0010 0020 0010 0020 0030 0020 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0020 0010 0010 0010 0010 0010 0010 0020 0010 0010 0010 0010 0010 0010 0010 0010 0020 0020 0010 0010 0010 0010 0010 0010 0020 0010 0010 0020 0010 0010 0020 0010 0010 09DD"
- delay: 60ms
- light.turn_off: status_light