
Unit 4Relay is a Unit with four integrated relays controlled over I2C. Each relay supports up to AC 250V / DC 28V, rated 10A, with a peak of 16A. Every relay can be controlled independently, and each channel has a programmable status LED.
Because Unit 4Relay is driven by an onboard STM32, you need an external_component to handle I2C communication.
Enable the I²C component in ESPHome:
# Example configuration entry for ESP32
i2c:
sda: GPIOXX
scl: GPIOXX
scan: true The GPIO pins vary by controller. For example, using Atom Lite as the controller:
# I2C Bus on Grove Port (HY2.0-4P)
i2c:
sda: GPIO26
scl: GPIO32 Example configuration for Unit 4Relay:
external_components:
- source: https://github.com/m5stack/esphome-yaml/tree/main/components
components: unit4relay
refresh: 0s
unit4relay:
switch:
- platform: unit4relay
relay_1:
name: "Relay Channel 1"
restore_mode: RESTORE_DEFAULT_OFF
relay_2:
name: "Relay Channel 2"
restore_mode: RESTORE_DEFAULT_OFF
relay_3:
name: "Relay Channel 3"
restore_mode: RESTORE_DEFAULT_OFF
relay_4:
name: "Relay Channel 4"
restore_mode: RESTORE_DEFAULT_OFF
This uses the default LED behavior: turning on a channel switch lights the corresponding LED.
# Example configuration entry
unit4relay: relay_1 (Optional): Relay switch for channel 1. Defaults to false.
All options from Switch
relay_2 (Optional): Relay switch for channel 2. Defaults to false.
All options from Switch
relay_3 (Optional): Relay switch for channel 3. Defaults to false.
All options from Switch
relay_4 (Optional): Relay switch for channel 4. Defaults to false.
All options from Switch
After adding the device to the Dashboard, you can control relay on/off actions in Home Assistant.
