Skip to content

Instantly share code, notes, and snippets.

@lollilol
Last active September 21, 2026 08:53
Show Gist options
  • Select an option

  • Save lollilol/8c8842089bf4ff872d551cacf3f929ae to your computer and use it in GitHub Desktop.

Select an option

Save lollilol/8c8842089bf4ff872d551cacf3f929ae to your computer and use it in GitHub Desktop.
remote control a Sony TA-FE330R using an esp32 and an infrared diode
esphome:
name: sony-amp-ir
friendly_name: Sony Amp IR
esp32:
board: esp32dev
framework:
type: esp-idf
logger:
api:
encryption:
key: !secret api_enc_key
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.178.8
gateway: 192.168.178.1
subnet: 255.255.255.0
enable_btm: true
remote_transmitter:
pin: GPIO4
carrier_duty_percent: 50%
non_blocking: True
script:
- id: send_sony
parameters:
command: int
then:
- remote_transmitter.transmit_raw:
carrier_frequency: 40kHz
# This lambda generates the SIRC pulse train:
# Header: 2400us high, 600us low
# Data: 1200us high (1) or 600us high (0), followed by 600us low
code: !lambda |-
std::vector<long int> control;
uint16_t data = (16 << 7) | (command & 0x7F);
for (int r = 0; r < 3; r++) { // Repeat 3 times
// Header
control.push_back(2400);
control.push_back(-600);
// 12 bits LSB first
for (int i = 0; i < 12; i++) {
if ((data >> i) & 1) {
control.push_back(1200); // Bit 1
} else {
control.push_back(600); // Bit 0
}
control.push_back(-600); // Space
}
// Gap between repeats (Sony standard is ~45ms total cycle)
control.push_back(-25000);
}
return control;
button:
- platform: template
name: Power
on_press:
- script.execute:
id: send_sony
command: 21
- platform: template
name: Power On
on_press:
- script.execute:
id: send_sony
command: 46
- platform: template
name: Power Off
on_press:
- script.execute:
id: send_sony
command: 47
- platform: template
name: Volume Up
on_press:
- script.execute:
id: send_sony
command: 18
- platform: template
name: Volume Down
on_press:
- script.execute:
id: send_sony
command: 19
- platform: template
name: Tuner
on_press:
- script.execute:
id: send_sony
command: 33
- platform: template
name: Tape
on_press:
- script.execute:
id: send_sony
command: 35
- platform: template
name: Tape2
on_press:
- script.execute:
id: send_sony
command: 36
- platform: template
name: CD
on_press:
- script.execute:
id: send_sony
command: 37
- platform: template
name: AUX
on_press:
- script.execute:
id: send_sony
command: 29
- platform: template
name: Video1
on_press:
- script.execute:
id: send_sony
command: 34
- platform: template
name: Video2
on_press:
- script.execute:
id: send_sony
command: 30
- platform: template
name: Phono
on_press:
- script.execute:
id: send_sony
command: 32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment