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

I dont remember playing with inverting remote_transmitter though, so i will

I can’t even get it to compile with inverted: true anywhere I can think to try it in either remote_transmitter or remote_transmitter.transmit_pronto :rofl:
Maybe its only a thing for remote_transmitter.transmit_rc_switch_type_a?

If what I’m capturing doesnt start with -/minus, and then sends OK… That means I’ve got to have this the right way round (and there’s some other reason for my troubles with pronto codes) doesn’t it? :worried:

Yeah if what you’re receiving raw isn’t negative that you should already have it the right way round as you say. Have you tried playing with the tolerance when you’re decoding/sending pronto data? Looks like you’ve made it tighter than the default which is maybe affecting things?

I made it tighter hoping to improve how codes are recognised, but it didnt at all.
I tried setting it to a few petty random numbers but saw no difference

I’ve done some looking into the inconsistent data error and I think it happens when the pronto data you’re sending is too long and then gets truncated.

But this is kind of secondary to another thing that seems to be happening, which is that I think you’re getting a really long pronto code because the input signal is varying too much for the library to decode and separate the repeats from each other, which may be affected by that tolerance config option?

I’m thinking if you make the tolerance higher/wider, you might get shorter pronto codes

Edit: Reading tolerance docs and source I’m getting confused whether you want a higher or lower value in this case to be honest :upside_down_face:

Try moving the remote further away from your unit when you’re learning the codes, it might help to get less varied signals so the lib can see the repeats

Just tried a few different tolerances:

Tolerance 0
[22:09:39][I][remote.pronto:233]: Received Pronto: data=
[22:09:39][I][remote.pronto:235]: 0000 006D 0022 0000 00A7 00B0 0013 0044 0012 0045 0012 0044 0011 001A 0011 0019 0012 0019 0013 0019 0014 0018 0013 0044 0013 0043 0012 0045 0012 0019 0013 0018 0012 0019 0013 0018 0011 001A 0011 001A 0011 001B 0012 0019 0011 0044 
[22:09:39][I][remote.pronto:235]: 0013 0018 0012 0045 0012 0045 0013 0017 0012 0046 0011 0044 0012 0047 000E 001A 0011 0045 0013 0018 0013 0018 0012 0045 0012 0181 06C3

Tolerance 25
[22:06:25][I][remote.pronto:233]: Received Pronto: data=
[22:06:25][I][remote.pronto:235]: 0000 006D 0022 0000 00A8 00AF 0013 0045 0012 0043 0013 0043 0014 0017 0014 0018 0014 0018 0012 0019 0013 0018 0013 0044 0013 0043 0014 0043 0013 0018 0014 0018 0013 0018 0013 0018 0012 001A 0012 0018 0012 0019 0012 0019 0012 0044 
[22:06:25][I][remote.pronto:235]: 0013 0017 0014 0045 0011 0043 0012 0019 0012 0045 0012 0044 0013 0043 0013 0018 0014 0043 0013 0018 0014 0018 0012 0045 0012 0181 06C3
[22:06:25][I][remote.samsung:061]: Received Samsung: data=0xE0E016E9, nbits=32

Tolerance 50
[22:03:35][I][remote.jvc:049]: Received JVC: data=0xE0E0
[22:03:35][I][remote.lg:054]: Received LG: data=0xE0E016E9, nbits=32
[22:03:35][I][remote.pronto:233]: Received Pronto: data=
[22:03:35][I][remote.pronto:235]: 0000 006D 0022 0000 00A8 00AF 0014 0043 0014 0043 0013 0043 0013 0018 0014 0017 0014 0018 0012 0019 0012 0019 0012 0045 0012 0045 0012 0043 0013 0018 0013 0018 0014 0018 0013 0018 0014 0017 0014 0018 0014 0017 0014 0018 0012 0046 
[22:03:35][I][remote.pronto:235]: 0011 0019 0013 0044 0012 0043 0014 0017 0014 0043 0013 0043 0014 0043 0013 0018 0012 0045 0012 0019 0012 0019 0012 0045 0012 0181 06C3
[22:03:35][I][remote.samsung:061]: Received Samsung: data=0xE0E016E9, nbits=32

Tolerance 75
[22:05:01][I][remote.jvc:049]: Received JVC: data=0xFFFF
[22:05:01][I][remote.lg:054]: Received LG: data=0xFFFFFFFF, nbits=32
[22:05:01][I][remote.nec:097]: Received NEC: address=0xFFFF, command=0xFFFF command_repeats=1
[22:05:01][I][remote.pronto:233]: Received Pronto: data=
[22:05:01][I][remote.pronto:235]: 0000 006D 0022 0000 00A8 00AF 0013 0045 0012 0045 0012 0043 0014 0017 0014 0018 0014 0017 0014 0018 0013 0018 0014 0044 0013 0042 0013 0044 0012 0019 0012 0019 0012 0019 0013 0017 0014 0018 0014 0017 0014 0018 0014 0017 0014 0044 
[22:05:01][I][remote.pronto:235]: 0013 0018 0013 0044 0012 0045 0012 0019 0012 0045 0011 0045 0012 0046 0011 0018 0014 0043 0013 0018 0012 0019 0012 0044 0012 0181 06C3
[22:05:01][I][remote.rc_switch:261]: Received RCSwitch Raw: protocol=3 data='00000000000000000000000000000000'
[22:05:01][I][remote.samsung:061]: Received Samsung: data=0xFFFFFFFF, nbits=32

Tolerance 100
[22:07:58][I][remote.jvc:049]: Received JVC: data=0xFFFF
[22:07:58][I][remote.lg:054]: Received LG: data=0xFFFFFFFF, nbits=32
[22:07:58][I][remote.nec:097]: Received NEC: address=0xFFFF, command=0xFFFF command_repeats=1
[22:07:58][I][remote.pronto:233]: Received Pronto: data=
[22:07:58][I][remote.pronto:235]: 0000 006D 0022 0000 00A8 00AF 0013 0044 0012 0045 0012 0044 0013 0018 0014 0017 0014 0018 0015 0016 0014 0018 0013 0044 0012 0045 0012 0045 0012 0019 0012 0019 0012 0018 0013 0018 0014 0017 0014 0018 0014 0017 0014 0018 0013 0043 
[22:07:58][I][remote.pronto:235]: 0012 0019 0013 0044 0012 0044 0012 0019 0012 0043 0012 0045 0013 0043 0014 0017 0014 0044 0012 0019 0012 0019 0013 0044 0012 0181 06C3
[22:07:58][I][remote.drayton:230]: Received Drayton: address=0x0000 (0x0000), channel=0x000 command=0x000
[22:07:58][I][remote.rc_switch:261]: Received RCSwitch Raw: protocol=3 data='00000000000000000000000000000000'
[22:07:58][I][remote.samsung:061]: Received Samsung: data=0xFFFFFFFF, nbits=32

This is with my Samsung TV remotes OK/Enter button
The pronto data doesn’t seem to change length at all, but I do get Samsung codes at 25%-100%.
The one I got with 25% and 50% (0xE0E016E9) works perfectly.

When I was recording button IR codes last night, I think I started with the remote from a cheap fan I’ve got, cranked down the tolerance and ended up setting it to capture raw so didn’t even look for ‘proper’ codes when I got to my TV remote. :man_facepalming:

Guess I’ll be doing a bunch of that again!
Thanks for sending me in the direction that lead to finding that

Great stuff, yeah it does look like 25% is best - you can see the signal is getting more false positives as the tolerance goes up and no perfect matches at 0. I understand that config too now at last :wink:

So if you wanna try the “learn” thing again, here’s it updated for samsung:


# Home Assistant controlled fake switch - to enable "learning mode"
switch:
  - platform: template
    name: Learn Command
    id: remote_learn_switch
    optimistic: true

# Home Assistant sensor to store remote command data
text_sensor:
  - platform: template
    name: Learned Command
    id: learned_command

remote_receiver:
  pin:
    number: P7
    inverted: true
    mode:
      # INPUT_PULLUP # Seems to do the same as seperate input & pullup
      input: true
      pullup: true
  on_samsung:
    - if:
        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(x.data) + ", nbits = " + esphome::to_string(x.nbits);
              id(learned_command).publish_state(log_output.c_str());
          - delay: 80ms
          - light.turn_on: ir_status_light
          - delay: 500ms
          - light.turn_off: ir_status_light
  # # On all received pronto data
  # on_pronto:
  #   - if:
  #       condition:
  #         # If Remote Learn switch is on
  #         lambda: 'return id(remote_learn_switch).state;'
  #       then:
  #         # - Turn learn switch off
  #         # - Build data string
  #         # - Publish data string to text sensor
  #         - lambda: |-
  #             id(remote_learn_switch).publish_state(false);
  #             std::string log_output = "Pronto: Data = " + esphome::to_string(x.data);
  #             id(learned_command).publish_state(log_output.c_str());
  #         # Blink status LED
  #         - delay: 80ms
  #         - light.turn_on: ir_status_light
  #         - delay: 500ms
  #         - light.turn_off: ir_status_light
  # # Using SONY protocol instead
  # 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: ir_status_light
  #         - delay: 500ms
  #         - light.turn_off: ir_status_light


With that, the shorter Samsung codes (like 0xE0E016E9) make it into HA:
image

They have a bunch of 0s added though :thinking:

I guess it’d make sense to uncomment each block, and add more, for the common code standards. With the type of code ending up in HA, that should mean not having to go through the log…

Huh strange that’ll be something going on with the type of int for the samsung data - i don’t see leading zeros with sony. Will just need to fiddle with the conversion to a hex string a bit

I haven’t got samsung myself so try this to remove the leading 0s:

  on_samsung:
    - if:
        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: ir_status_light
          - delay: 500ms
          - light.turn_off: ir_status_light

Spot on:
image
Thanks very much again!

After adding this in though, I see a few strange connection problems after uploading it:

INFO Successfully uploaded program.
INFO Starting log output from 192.168.5.43 using esphome API
INFO Successfully connected to irblaster @ 192.168.5.43 in 19.531s
WARNING irblaster @ 192.168.5.43: Connection error occurred: irblaster @ 192.168.5.43: EOF received
WARNING Can't connect to ESPHome API for irblaster @ 192.168.5.43: Error while finishing connection: Finishing connection cancelled due to fatal exception: irblaster @ 192.168.5.43: EOF received (SocketClosedAPIError)
INFO Trying to connect to irblaster @ 192.168.5.43 in the background
INFO Successfully connected to irblaster @ 192.168.5.43 in 0.004s
WARNING irblaster @ 192.168.5.43: Connection error occurred: irblaster @ 192.168.5.43: EOF received
INFO Successfully connected to irblaster @ 192.168.5.43 in 0.006s
WARNING irblaster @ 192.168.5.43: Connection error occurred: irblaster @ 192.168.5.43: EOF received
INFO Successfully connected to irblaster @ 192.168.5.43 in 0.009s
INFO Successful handshake with irblaster @ 192.168.5.43 in 0.260s
[E][json:041]: Could not allocate memory for JSON document! Requested 512 bytes, largest free heap block: 1080 bytes

…then it carries on OK as usual.

It doesnt seem to affect anything other than the first few seconds after upload though, so all’s good

Thanks again

In case it’s of use to anyone else, this is all of it:

esphome:
  name: irblaster
  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            # include intrnal entities
  # local: true                       # Load everything locally rather than over the web

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                # 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
    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_PULLUP # Seems to do the same as seperate input & pullup
      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
  - platform: template
    name: Fan Timer
    icon: mdi:fan-clock
    turn_on_action:
      - light.turn_on: status_light
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [1174, -378, 1312, -371, 476, -1212, 1315, -372, 1334, -353, 468, -1253, 434, -1226, 461, -1219, 1315, -372, 472, -1225, 458, -1222, 465, -7984, 1315, -355, 1315, -372, 468, -1242, 1289, -378, 1309, -375, 482, -1205, 469, -1221, 466, -1242, 1292, -371, 469, -1222, 465, -1245, 445, -8004, 1272, -378, 1312, -371, 472, -1215, 1331, -356, 1316, -371, 469, -1242, 445, -1222, 465, -1218, 1305, -383, 472, -1215, 468, -1242, 445, -7959, 1323, -372, 1301, -386, 437, -1253, 1309, -378, 1278, -406, 472, -1184, 468, -1241, 446, -1222, 465, -1239, 449, -1221, 465, -1219, 523]
      - delay: 60ms
      - light.turn_off: status_light
  - platform: template
    name: Fan Mode
    icon: mdi:fan-auto
    turn_on_action:
      - light.turn_on: status_light
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [1151, -441, 1246, -409, 438, -1277, 1253, -434, 1269, -419, 406, -1284, 403, -1304, 383, -1284, 403, -1280, 1273, -414, 422, -1272, 399, -8015, 1284, -417, 1256, -431, 406, -1305, 1226, -444, 1243, -440, 406, -1278, 409, -1278, 406, -1303, 384, -1284, 1253, -431, 406, -1284, 403, -8014, 1264, -458, 1229, -441, 403, -1282, 1304, -383, 1317, -371, 407, -1305, 414, -1253, 404, -1284, 403, -1285, 1313, -372, 437, -1271, 417, -7994, 1293, -403, 1305, -383, 438, -1253, 1281, -426, 1266, -403, 435, -1250, 444, -1244, 437, -1254, 434, -1274, 1261, -403, 438, -1254, 434, -7994, 1305, -366, 1306, -376, 475, -1212, 1317, -371, 1335, -354, 468, -1223, 465, -1243, 445, -1222, 466, -1219, 1305, -383, 449, -1246, 431, -7987, 1285, -418, 1253, -434, 407, -1274, 1265, -434, 1247, -441, 406, -1247, 441, -1247, 438, -1272, 416, -1253, 1283, -433, 407, -1254, 434, -8018, 1265, -462, 1226, -441, 403, -1250, 1308, -411, 1254, -434, 375, -1305, 383, -1285, 403, -1285, 406, -1279, 410, -1278, 406, -1276, 412, -8037, 1251, -403, 1308, -380, 437, -1254, 1295, -409, 1310, -362, 437, -1298, 392, -1245, 438, -1255, 528, -1180, 413, -1254, 434, -1260, 428]
      - 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:wall-sconce-flat-outline
    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
    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 Source
    icon: mdi:television
    turn_on_action:
      - light.turn_on: status_light
      - remote_transmitter.transmit_samsung:
          data: 0xE0E0807F
      - 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
  - platform: template
    name: TV Vol+
    icon: mdi:volume-plus
    turn_on_action:
      - light.turn_on: status_light
      - remote_transmitter.transmit_samsung:
          data: 0xE0E0E01F
      - delay: 60ms
      - light.turn_off: status_light
  - platform: template
    name: TV Vol-
    icon: mdi:volume-minus
    turn_on_action:
      - light.turn_on: status_light
      - remote_transmitter.transmit_samsung:
          data: 0xE0E0D02F
      - delay: 60ms
      - light.turn_off: status_light
  - platform: template
    name: TV Channel+
    icon: mdi:chevron-up
    turn_on_action:
      - light.turn_on: status_light
      - remote_transmitter.transmit_samsung:
          data: 0xE0E048B7
      - delay: 60ms
      - light.turn_off: status_light
  - platform: template
    name: TV Channel-
    icon: mdi:chevron-down
    turn_on_action:
      - light.turn_on: status_light
      - remote_transmitter.transmit_samsung:
          data: 0xE0E008F7
      - delay: 60ms
      - light.turn_off: status_light
  - platform: template
    name: TV Guide
    icon: mdi:television-guide
    turn_on_action:
      - light.turn_on: status_light
      - remote_transmitter.transmit_samsung:
          data: 0xE0E0F20D
      - delay: 60ms
      - light.turn_off: status_light
# PC
  - platform: template
    name: Ambilight On
    icon: mdi:television-ambient-light
    turn_on_action:
      - light.turn_on: status_light
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [2557, -875, 438, -434, 469, -406, 472, -871, 469, -885, 1334, -882, 431, -406, 472, -437, 466, -406, 469, -413, 462, -437, 469, -426, 451, -406, 468, -444, 461, -438, 437, -407, 944, -431, 437, -406, 477, -398, 502, -405, 472, -872, 437, -438, 468, -458, 418, -406, 910, -903, 437, -438, 437, -438, 906, -875, 875, -478, 431, -403, 469, -882, 899]
      - delay: 60ms
      - light.turn_off: status_light
  - platform: template
    name: Ambilight Off
    icon: mdi:television-ambient-light
    turn_on_action:
      - light.turn_on: status_light
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [2576, -897, 456, -406, 476, -399, 469, -890, 464, -865, 1350, -868, 453, -406, 454, -437, 469, -413, 462, -406, 469, -438, 482, -393, 468, -407, 475, -431, 469, -406, 469, -409, 934, -407, 475, -400, 468, -438, 469, -888, 424, -406, 476, -431, 468, -407, 468, -413, 934, -879, 431, -406, 469, -437, 920, -861, 913, -400, 469, -406, 475, -869, 912]
      - delay: 60ms
      - light.turn_off: status_light
# Kodi:
  - platform: template
    name: Kodi OK
    icon: mdi:kodi
    turn_on_action:
      - light.turn_on: status_light
      - remote_transmitter.transmit_raw:
          carrier_frequency: 38kHz
          code: [2564, -864, 434, -438, 437, -451, 455, -875, 441, -871, 1361, -858, 469, -440, 434, -438, 437, -438, 485, -421, 437, -438, 440, -435, 468, -438, 437, -448, 427, -437, 469, -441, 871, -438, 468, -448, 427, -438, 437, -878, 466, -437, 438, -447, 459, -406, 468, -438, 909, -840, 476, -430, 438, -437, 438, -440, 903, -885, 459, -406, 468, -438, 878, -872, 478]
      - delay: 60ms
      - light.turn_off: status_light

…bits of it really aren’t necessary tbh. First ESP project though, so I’ve been trying all sorts and pretty much left in anything that works well :smile:

3 Likes

Huh how weird, and that’s only after uploading? You’ve not seen that happen since?

It only seems to happen for a few seconds after I upload something, I’ve not seen it any other time. It’s as if the ESPs taking a bit longer to start up fully.
Far from a big issue, it only ends up being a few seonds delay.

I’ve got one last thing I’d like to change about this IR gadget if possible, but I’ve not been able to figure out how yet.
It doesn’t need to be listening for IR codes all the time, so I’d like to make it only listen once the remote_learn_switch is pressed in HA.
It seems to hate me trying to make remote_receiver rely on a switch.
It’s nearly pub-o’clock though, so I’ll have another look with fresh eyes some other time.

Just added what this can control into a couple of automations.
When I go to bed or go out, if the TV’s on it turns if off. Simple but effective.
Pings the TV, that the automation does using ‘Home Assistant Core Integration: Update entity’ once as I leave (better than the ping happening every x seconds). If the ping gets a reply it sends the TV power IR code.
Doesnt need a ping that runs all the time, and doesnt turn the TV on if it was off.
Works a treat.

1 Like

Okay, I’m a n00b at flashing Tuya devices, and worse about connecting to them. Is there something else needed for a serial/uart connection besides GND, TX, and RX? I know about CEN chip enable, and am grounding it while applying power, but there is no positive feedback of any kind from the CB3S module. :frowning: Picture of my connections (yeah, they’re lousy) below.

I’m a n00b at it too.
It might be possible to flash the thing wirelessly, TBH I never tried. It might seem like cheating now you’ve got your soldering iron out, but maybe give CouldCutter a shot if you’ve got a Pi.
The connection’s don’t need to be pretty, mine certainly weren’t. The solder on the end of the purple wire isn’t touching that metal can though, is it?

I guess you’re just touching wire to other pads as you try to connect things?
I did similar but just with the other ends of wires I’d soldered to the CB3S.
IIRC, it took me a few goes to get it talking.

I don’t think I saw anything over serial before getting ltchiptool to identify the chip, then I just did the same again and flashed esphome-kickstart… the stock firmware didn’t give any chatter that’d confirm things are connected.
What are you using to connect to it exactly?

1 Like

It’s ltchiptool version 4.11.1 (latest). I’ve been reading, and apparently the timing of making and breaking that CEN-to-GND connection is somewhat critical to the process. I’m going to give it another shot with a bit more patience after work today. Someone else said to ground CEN to the CB3S module itself, but there’s clear electrical continuity with ground on the USB power port, and the AMS1117 LDO voltage regulator. That purple wire is definitely not connected to the shield/can. That’s just one last blob of excess solder I didn’t scrape off the can earlier today. And THANK YOU for replying so quickly. Much appreciated.

I do have a Pi available, just need to dig it off the shelf and find a micro-SD card to get it booted into Linux. I’ll give the direct connection a few more tries, first.

Tbh I just happened to open the forum and saw a notification.
(I’ve never got email notifications to work here so don’t see if I don’t happen to have it open. Just had another look and might have found the right setting though, so we’ll see)

Where you ground it to really shouldn’t make much difference, it’s all effectively the same. IIRC I touched the wire to the end fo the one I’d soldered to the CB3S board.

The timing made a big difference when I did it, it definitely took a few tries.
I don’t remember well enough to explain exactly what it needed though, sorry.
Best I can do is: ground it as you connect power and disconnect it a short time (a second or two) before you click anything that’ll make the software talk to the chip.
Looking at my own pic though, I’d soldered a wire to the rest pad too.
It may have been havig CEN and Reset grouded as I applied power, then disconnecting reset just before hitting a button

I never offered up the original firmware to here, as I hadn’t removed it from my Tuya setup first.
If you remove it from your tuya/smartlife app first (deleting data), that dump might be useful to someone if you’re up for it.

(Then once you’ve re-found the timing, we should probably add it to the devices page, as I didn’t get round to originally :smile:)

Thinking about it… you could probably skip the esphome kickstart entirely.

I didn’t know the board setup to use in eshome at the time, so couldn’t produce anything I knew I could flash to the board…
Now I know this does the trick though, you could probably add it into ESPHome and make your own ‘proper’ esphome file to flash straight away:

bk72xx:
  board: cb3s # https://docs.libretiny.eu/boards/cb3s/

…then flashing that file with esphome flasher could be a 2nd, more direct, option.

Thanks for the follow-up messages! I zonked out VERY early last night, didn’t get back to it until today. Connected a puTTY session to UART2 TX2 on the BK72xx module, and didn’t see anything. Seems if you leave CEN chip enable permanently shorted to GND, it never boots up. :confounded: When I began pulling wires loose thinking it was just a bad chip altogether, the debug output came up on the puTTY session. Now knowing it’s okay/good, I started setting up an RPi to run tuya-cloudcutter today. For some silly reason, “work” took priority. No progress since getting it setup, but will continue to pursue it after work today.