pdf-icon

Unit 4Relay Home Assistant Integration

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.

Note
Unit 4Relay is a standalone relay/switch platform. You need an additional main controller (Atom series, Stamp series, Stick series, Core/Basic series, etc.) to integrate it into Home Assistant.

Because Unit 4Relay is driven by an onboard STM32, you need an external_component to handle I2C communication.

Configure the relays

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:

yaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
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.

Configurable variables

Component/Hub

# Example configuration entry
unit4relay:
  • id (Optional, ID): Specify an ID for Unit 4Relay component.

Switch

  • 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

Add the relays to Home Assistant

After adding the device to the Dashboard, you can control relay on/off actions in Home Assistant.

On This Page