pdf-icon

Unit 4Relay Home Assistant Integration

This chapter introduces the configuration methods and practical steps for integrating the Unit 4Relay relay into Home Assistant.

Note

  • Since Unit 4Relay is a standalone relay/switch platform, it requires an additional main controller (such as Atom series, Stamp series, Stick series, Core/Basic series, etc.) to be integrated into Home Assistant.
  • Because Unit 4Relay is controlled by a built-in STM32, external_components are required to implement I2C communication control.

Relay Configuration

The I²C component needs to be enabled in the ESPHome configuration:

# Example configuration entry for ESP32
i2c:
  sda: GPIOXX
  scl: GPIOXX
  scan: true

The GPIO pins here vary depending on the main controller device used. For example, using Atom Lite as the main controller:

# I2C Bus on Grove Port (HY2.0-4P)
i2c:
  sda: GPIO26
  scl: GPIO32

Unit 4Relay configuration example:

yaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
external_components:
  - source: github://m5stack/esphome-yaml/components@main
    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

Default light control is used here: when the switch for the corresponding channel is turned on, the corresponding LED will light up.

Configurable Options

Components

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

Switch

  • relay_1 (Optional): Relay switch for channel 1. Default is false (off), and all other configuration options supported by Switch.

  • relay_2 (Optional): Relay switch for channel 2. Default is false (off), and all other configuration options supported by Switch.

  • relay_3 (Optional): Relay switch for channel 3. Default is false (off), and all other configuration options supported by Switch.

  • relay_4 (Optional): Relay switch for channel 4. Default is false (off), and all other configuration options supported by Switch.

Quick Start

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

Video

On This Page