Skip to content

Instantly share code, notes, and snippets.

@jmassardo
Created November 17, 2025 02:04
Show Gist options
  • Select an option

  • Save jmassardo/e869b9569e7accee7b3c1b2cfcdf3198 to your computer and use it in GitHub Desktop.

Select an option

Save jmassardo/e869b9569e7accee7b3c1b2cfcdf3198 to your computer and use it in GitHub Desktop.
I bought a cheap relay board off Amazon for my landscape lights. I couldn't find a good example of a config so I had to hack around on it until I figured out how to make it work. Hopefully this helps someone else.
# ESPHome file for accessing serial relays on a Eujgoov 4-Channel WiFi Smart Home Relay Module
# https://www.amazon.com/dp/B09LQNYPHQ
esphome:
name: relay-controller
friendly_name: relay-controller
esp8266:
board: esp01_1m
framework:
version: recommended
# Enable logging
logger:
baud_rate: 0 # Disable serial logging since we're using UART for relay control
# Enable Home Assistant API
api:
encryption:
key: "My-super-secret-encryption-key"
ota:
- platform: esphome
password: "My-super-secret-ota-password"
wifi:
ssid: "Pretty Fly for a WiFi"
password: 8675309
web_server:
port: 80
uart:
tx_pin: GPIO1
rx_pin: GPIO3
baud_rate: 115200
debug:
direction: BOTH
dummy_receiver: true
after:
delimiter: "\n"
sequence:
- lambda: UARTDebug::log_hex(direction, bytes, ':');
switch:
- platform: template
name: "Relay 1"
id: relay_1
optimistic: true
turn_on_action:
- uart.write: [0xA0, 0x01, 0x01, 0xA2]
- delay: 100ms
turn_off_action:
- uart.write: [0xA0, 0x01, 0x00, 0xA1]
- delay: 100ms
- platform: template
name: "Relay 2"
id: relay_2
optimistic: true
turn_on_action:
- uart.write: [0xA0, 0x02, 0x01, 0xA3]
- delay: 100ms
turn_off_action:
- uart.write: [0xA0, 0x02, 0x00, 0xA2]
- delay: 100ms
- platform: template
name: "Relay 3"
id: relay_3
optimistic: true
turn_on_action:
- uart.write: [0xA0, 0x03, 0x01, 0xA4]
- delay: 100ms
turn_off_action:
- uart.write: [0xA0, 0x03, 0x00, 0xA3]
- delay: 100ms
- platform: template
name: "Relay 4"
id: relay_4
optimistic: true
turn_on_action:
- uart.write: [0xA0, 0x04, 0x01, 0xA5]
- delay: 100ms
turn_off_action:
- uart.write: [0xA0, 0x04, 0x00, 0xA4]
- delay: 100ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment