I think I’ve cracked it. It’s reliably turning my TV and a fan on/off just as I was hoping
Still got to record and then set up a list of other remote buttons, but I’ve got the process for doing that working pretty well.
I may well tweak this a bit more, but in case it mght help out anyone else, this is what I’ve got so far:
esphome:
name: smartirblaster
friendly_name: IR_Blaster
bk72xx:
board: cb3s # https://docs.libretiny.eu/boards/cb3s/
# Enable logging. https://esphome.io/components/logger.html
logger:
# Enable Home Assistant API.
api:
encryption:
key: !secret api_encryption_key
ota:
password: !secret ota_password
safe_mode: True
# WiFi connection details. Without domain:, defaults to .local. https://esphome.io/components/wifi.html
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
domain: .home
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
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
local: true
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
- 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
name: "Uptime Seconds"
entity_category: "diagnostic"
disabled_by_default: true # Shows entity in HA, but disabled by default
text_sensor:
- platform: template # From https://community.home-assistant.io/t/uptime-sensor-in-hours-or-days/116392/28 Thanks JayElDubya & SpikeyGG
name: Uptime
# update_interval: 10s
icon: mdi:timer-outline
lambda: |-
int seconds = (id(uptime_seconds).state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
if ( days > 3650 ) {
return { "Starting up" };
} else if ( days ) {
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( hours ) {
return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( minutes ) {
return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else {
return { (String(seconds) +"s").c_str() };
}
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: LED # Makes it show in HA
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
remote_receiver:
pin:
number: P7
inverted: true
mode:
# INPUT_PULLUP # Seems to do the same as seperate input & pullup
input: true
pullup: true
tolerance: 10
# dump: all # Kept giving Pronoto codes that wouldn't send 'Inconsistent data, not sending'
# dump: pronto
dump: raw
remote_transmitter:
pin: P26
# Infrared remotes use a 50% carrier signal
carrier_duty_percent: 50%
switch:
- platform: template
name: TV Power
turn_on_action:
- remote_transmitter.transmit_raw:
carrier_frequency: 38kHz
code: [4376, -4566, 492, -1729, 521, -1720, 531, -1723, 528, -594, 531, -594, 538, -588, 531, -594, 500, -625, 531, -1726, 525, -1687, 538, -1711, 531, -594, 531, -600, 524, -594, 531, -594, 531, -594, 531, -593, 531, -1719, 500, -631, 493, -625, 500, -625, 499, -594, 563, -568, 525, -593, 531, -1719, 537, -587, 687, -1563, 531, -1727, 522, -1718, 506, -1743, 500, -1760, 490, -1718, 531]
- platform: template
name: Fan On
turn_on_action:
- 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]
Please be kind, it’s my first time doing anything with an ESP or ESPHome
I’ve defined the button but aren’t using it.
The LED is just a status LED in case of error, but probably could be used in some other way as well?
Any suggestions are welcome