What's right to put on bk7231n based IR blaster to make it usable in HA?

Sounds like you’re getting there.
If ClouldCutter doesnt do it, I bet you’re close to getting the timing right with the serial approach. Do the same and then read the chips details or upload something and it’d probably do the trick.

Just in case it’s of any use, there isn’t much difference to what I’ve posted previously, but below is what mines been running for the last few weeks.

Be ware that it seems to be close to some limit (that I don’t fully understand yet)… add more remote codes and you might find it starts to take longer to boot and to connect to HA. So remove or comment out any of mine you don’t want, rather than just adding to the list.
Whatever this limit is, I think it’s what I started hitting when I tried out @WaresMyHass’ trick for getting the recorded codes to show in HA. It’s why I’ve turned off the web server too.
I’ve ended up with quite a list of remote codes in there for controlling my TV and Kodi that I watch everything through. With a smaller list you could use either OK again.

It was too long to post in one message, so I’ve chopping out the codes I’d found but don’t use so had commented out:

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

button:
  - platform: restart
    id: reboot
    name: "Reboot"

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%

switch:
## 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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
    turn_on_action:
      - 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

I’ve seen a few reports around the forums of the chips being sensitive to power supply (if powering externally when serial flashed).

So worth investigating that side of things if you are having issues. Apparently some of the serial adapters can be poor for this.

I was able to successfully use tuya-cloudcutter to this device. Checking out things now…

1 Like

Well done.
I thought I’d done it the hard way :smile:

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.
image

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

Well, the device is on my network, but how to flash it with ESPhome code, I have no clue. The USB-C port on the device is power-only (unless I’m mistaken). More reading to be done, or even 3D-printing a pogo-pin connector for the BK72xx module.

The port is power-only.

Getting stuff flashed from ESPHome took a little fiddling for me to begin with, but it end up being dead easy.
There’s 1 ‘rule’ - once you flash any OTA or API key to a device, do not lose that key or you’ll be flashing it the hard way again (ask me how I know :smile:)

Quick version:
Go to the ESPHome menu item down the left of HA
Hit + Add Device & follow the wizard.
You can skip/ignore anything that gives you that option and for the type of device though - they all add stuff to the YAML, that you have pretty much ready-made above anyway :wink:
Either copy the OTA and API keys somewhere else if you want to keep and use those. or ignore them and set blank ones in a minute.
Copy/paste what I’ve put above, replacing everything thats already there
Copy/paste the keys back in if you want to use them, or set your own, set them in a Secrets file like I have, or leave them out entirely.
Set the devices hostname (that it’ll use to upload to over wifi) as name on the very first line
Set any Friendly Name you’d like it to show up as in esphome
Set your own Wifi creds, hit Install and Wireless. :crossed_fingers:

1 Like

You are a VERY helpful and generous individual. THANK YOU!!

np. it’s only a little typing mate. It’s a learning curve I’ve only recently gone through myself, so I know what I got hung up on at least

…and that was all assuming you’ve already installed the ESPHome add-on, if you havent then do that first

Once you’ve got something uploaded to it through esphome, it should be automatically discovered and you should see a notification about a new device being found. Click that and then it should show as a device, where you can click on remote ‘buttons’ and make it do stuff.
There’s a Log option under the main ESPHome menu down the left, that’ll show any codes its received so you can then use them to create your own buttons for your own stuff.

Just out of interest… what use are you hoping to put it to, what will you be controlling?

I have an LG television to control, and possibly a few other devices to add later. Fortunately, I already have all the hex codes for the functions I need, having done an IR blaster previously.

Excellent, as long as you know the format the codes are then it’ll pretty much be renaming them and copy paste the codes.

Just in case you haven’t already found it, this might help if it needs anything different to what my stuff uses

For LG, it looks like each ‘button’ will need something like this:

  - platform: template
    name: YourButtonName
    icon: mdi:wall-sconce-flat-outline # icon name from https://pictogrammers.com/library/mdi/, or remove/comment this line if you don't care about an icon 
    on_press:
      - light.turn_on: status_light
      - remote_transmitter.transmit_lg:
          data: 0x20DF10EF # power on/off
          nbits: 32
      - delay: 60ms
      - light.turn_off: status_light

The light. and delay: lines just make the blasters blue LED flash when its sending codes. You could remove or comment them out if you dont want it to

I’m currently following the instructions here to install ESPhome with LibreTiny on the RPi running tuya-cloudcutter. Specifically, steps 10 and 11.

  1. Run the docker container to enable the ESPHome Dashboard with
    sudo docker run -d -v /opt/esphome:/config:rw -v /etc/localtime:/etc/localtime:ro -p '6052:6052/tcp' --name libretiny-esphome ghcr.io/libretiny-eu/libretiny-esphome-docker:latest

  2. Open a browser to your Raspberry Pi IP on port 6052. Example http://192.168.1.9:6052 This will allow you to build your ESPHome firmware for the device.

ah, a bit I didn’t do… Is that in the section thats labelled with ‘NO LONGER NECESSARY’?

Ignore me, there are two sets of 10 & 11 :man_facepalming:

Well, I double-checked my connections, and P16 (TXD) had lifted from the module. Unfortunately, there’s no brass/copper left on the module in that spot. Okay, purchased two of them, so wire up the second, where P16 is available. I can see ltchiptool sending requests to the bk7231n module, and the module is echoing them back, at least that’s what the LEDs on my UART say. But it never connects. I’m trying all sorts of P1 RST and P3 CEN to GND tricks, and none of them are eliciting any kind of positive response from ltchiptool. Just frustrating, is all.

Sounds a little rough, but maybe not the end of it with either…

Did you get anywhere with cloudcutter on the first one?
If you got its firmware replaced at all, you’ve still got a good chance.

When I got mine flashed after soldering to it and using my USB/serial adapter, it did take a little messing about timing-wise. Wish I could remember the ‘trick’… connecting to it was pretty reliable once I was getting it right.
Assuming we’ve got exactly the same thing hardware-wise, it really should be possible to do similar with your second one.

Okay, so after finally getting a decent night’s sleep, I was able to find @ferbulous video:
https://www.reddit.com/r/homeassistant/comments/zkl0n2/flash_ota_using_tuyacloudcutter_tuyaconvert_for/

Until this morning, I wasn’t aware tuya-cloudcutter would actually flash something else other than the cloudcutter code. Might be able to get further with it this morning, after all…

Nope, tuya-cloudcutter goes through the motions, finally fails with this (tried several times, all the same):

 $ sudo ./tuya-cloudcutter.sh -v -f ESPHome-Kickstart-v23.08.29_bk7231n_app.ota.ug.bin -p aubess-ir-remote-controller

DOH! :crazy_face: it SERIOUSLY helps if you remember to prefix that command with ‘sudo’, as there are a lot of nmcli network manager commands in the scripts requiring superuser access.

What it looks like when you execute it successfully:

Found access point name: "A-EBB9", trying to connect...
Device 'wlan0' successfully activated with '24acb230-c323-4abf-8865-e0e1a196eaf0'.
Connected to access point.
Configured device to connect to 'cloudcutterflash'
Device is connecting to 'cloudcutterflash' access point. Passphrase for the AP is 'abcdabcd' (without ')
Flashing custom firmware...

================================================================================
Wait for up to 10-120 seconds for the device to connect to 'cloudcutterflash'. This script will then show the firmware upgrade requests sent by the device.
================================================================================

Using WLAN adapter: wlan0
Configuration file: /dev/stdin
Using interface wlan0 with hwaddr dc:a6:32:8c:05:10 and ssid "cloudcutterflash"
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED
Using PSK v1 - Received PSK ID version 01
Processing endpoint /v2/url_config
Processing endpoint tuya.device.active
Processing endpoint tuya.device.dynamic.config.get
Processing endpoint tuya.device.property.save
Processing endpoint tuya.device.upgrade.get
Processing endpoint tuya.device.upgrade.status.update
Processing endpoint /files/ESPHome-Kickstart-v23.08.29_bk7231n_app.ota.ug.bin
Processing endpoint tuya.device.uuid.pskkey.get
Firmware update progress: 28%
Firmware update progress: 30%
Firmware update progress: 40%
Firmware update progress: 55%
Firmware update progress: 56%
Processing endpoint atop.online.debug.log
Processing endpoint tuya.device.dynamic.config.get
Processing endpoint tuya.device.dynamic.config.ack
Firmware update progress: 86%
[Firmware Upload] /files/ESPHome-Kickstart-v23.08.29_bk7231n_app.ota.ug.bin send complete, request range: bytes=0-561887/561888
Firmware update progress: 98%
Firmware file has been sent and MQTT reported a progress of nearly complete.  Waiting 15 seconds to ensure flashing completes.
Flashing should be complete.  It takes about 15 seconds for the device to reboot and verify the flash was valid.
Please wait about 30 seconds then look for signs of activity from the firmware you supplied (either watch for AP mode or check if it joined your network).
Device MAC address: a8:80:55:c8:eb:b9

Now, after this, the kickstart firmware will setup a wifi Access Point. You join it, select the wifi SSID and provide the password it needs, and it joins your network, whereupon you can load firmware using ESPHome over-the-air. Pretty neat. Except: the device has some kind of problem rebooting. It just flashes the led steadily, and never connects to the wifi. :frowning:

I have a couple of ESP-12F modules, I think I’ll be transplanting one to this board very soon.

1 Like

Did you try a hard reboot and then reflashing with a basic config including adding a static ip in your new config?

Also beware that I’ve seen some reports of LEDs flashing until you actually integrate it into HA.

Hard reboot (pull its USB cable for a minute or two, then reconnect it) is well worth it if you haven’t already.
After that, does it start its own network, do you see any new wifi SSID?

Kickstart did that for me, back in the first post in this thread.
I don’t know if or how cloudcutter might give it your wifi creds tbh. If it was given wifi creds, but it’s failing to connect to your wifi, you might have to wait a while for it’s acces point to show up.
If you do see any new SSID, connect to it leaving your wifi using DHCP first, but you might have to set a static IP on whatever device you’re connecting to it with.
Use its kickstart web page to give it your wifi creds (again) and hopefully you’ll be up and running. :crossed_fingers:
Scan the IPs on your network to see if it shows up, there are tons of little apps to do that on a windows machine, and I’m sure there are plenty that’d be similar for your Pi if you’re still using that.

I’m not sure what kickstart does with the LED exactly, it may well keep flashing until it’s connected to the esphome api. It’s a good indication the things running different firmware now at least!

Sounds like you’re really close, I bet you’ll have it running and connected in your next message or two :+1:

1 Like

Hi @mad-tunes.

Thanks a lot for doing most of the grinding for those of us with IRblasters on Bekens. I have a similar device, with a different version of the BK chip. I’ve already gotten ESPHome on it, together with the correct pinouts. It transmits and receives properly i think?

My problem is figuring out how you get it to learn codes from remotes and subsequently reimplement those codes back into the config as entities. I’m outputs like this for my Daikin HVAC remote

[15:37:18][I][remote.pronto:234]: Received Pronto: data=
[15:37:18][I][remote.pronto:236]: 0000 006D 0005 0000 0152 00AD 0015 0016 0016 0016 0017 0062 0016 0181 06C3
[15:37:18][I][remote.pronto:234]: Received Pronto: data=
[15:37:18][I][remote.pronto:236]: 0000 006D 001D 0000 0017 0016 0016 0017 0015 0016 0016 0042 0015 0042 0016 0042 0015 0042 0016 0042 0015 0042 0016 0042 0014 0042 0016 0017 0015 0016 0016 0042 0016 0016 0015 0016 0016 0016 0016 0017 0015 0016 0016 0016 0016 0042 
[15:37:18][I][remote.pronto:236]: 0015 0016 0016 0042 0015 0042 0016 0042 0015 0042 0016 0042 0015 0042 0016 0181 06C3
[15:37:18][I][remote.pronto:234]: Received Pronto: data=
[15:37:18][I][remote.pronto:236]: 0000 006D 0002 0000 0157 0051 0015 0181 06C3
[15:37:20][D][sensor:093]: 'Uptime': Sending state 1157.06006 s with 0 decimals of accuracy
[15:37:24][I][remote.jvc:049]: Received JVC: data=0x01FE
[15:37:24][I][remote.lg:054]: Received LG: data=0x01FE40BF, nbits=32
[15:37:24][I][remote.nec:097]: Received NEC: address=0x7F80, command=0xFD02 command_repeats=1
[15:37:24][I][remote.pioneer:149]: Received Pioneer: rc_code_X=0x0102
[15:37:24][I][remote.pronto:234]: Received Pronto: data=
[15:37:24][I][remote.pronto:236]: 0000 006D 0022 0000 0154 00AD 0016 0015 0017 0015 0017 0015 0017 0015 0016 0016 0016 0016 0016 0016 0015 0042 0016 0042 0016 0040 0016 0042 0016 0040 0016 0042 0016 0042 0015 0042 0016 0016 0016 0016 0015 0042 0016 0016 0016 0017 
[15:37:24][I][remote.pronto:236]: 0015 0016 0016 0016 0016 0016 0015 0016 0016 0042 0017 0016 0015 0042 0016 0042 0016 0042 0015 0042 0016 0042 0015 0042 0016 0181 06C3
[15:37:24][W][component:237]: Component remote_receiver took a long time for an operation (60 ms).
[15:37:24][W][component:238]: Components should block for at most 30 ms.
[15:37:24][I][remote.pronto:234]: Received Pronto: data=
[15:37:24][I][remote.pronto:236]: 0000 006D 0001 0000 0180 06C3
[15:37:24][I][remote.pronto:234]: Received Pronto: data=
[15:37:24][I][remote.pronto:236]: 0000 006D 0002 0000 0057 0013 0181 06C3

The learned command tab doesn’t seem to show anything

Thanks!

I found there’s really two parts to it… figuring out what kind of IR codes a device uses and then capturing whatever you want to use.

I’d try the shorter codes first (JVC, LG, NEC & Pioneer from your log), adding a button for each so you can run down the list and try them easily/quickly.
You can see how to send each type of code here.
Hopefully you’ll find one of the codes listed make your HVAC respond.
If none of those do the trick, try the same with Pronto.
After that you might have to resort to Raw.
Pronto and Raw seem less reproducable though, I found it best to capture a bunch and use that to find whatever’s most comonly received, aim for whatever looks most average.

That should let you figure out what kind of codes’ll work, then you change the dump: all line to capture just the relevant type of codes and capture other remote buttons from there.

The learned codes chunk is a really nice idea, but I found I hit some kind of size/memory limit about the time I was trying it so I didn’t end up using it. It’d need repeating for each type of code too, which I never ended up doing.

Edit:
It might be good to try it out with something that’s more likely to have a clear type of code first. HVAC stuff could use all sorts, but something like a big brand TV should be easier to get going, and would prove what you’ve got there works before getting too tied up with something more awkward.