English
English
简体中文
日本語

Unit 4Relay ESPHome Component

The Unit 4Relay component independently controls four relay outputs over I2C.

1. Component Overview

Item Information
Product Name Unit 4Relay
SKU U097
Main Function Independent control of four relays
Communication Interface I2C
Default I2C Address 0x26
ESPHome Component unit4relay (external component)
ESPHome Version Requirement /

2. Component Description

Including the External Component

Add the External Components configuration to the YAML file to load the Unit 4Relay component.

external_components:
  - source: github://m5stack/esphome-yaml/components
    components: [unit4relay]
    refresh: 0s

Switch Relay Control

Because Unit 4Relay is controlled by an onboard STM32, load the driver through external_components for I2C control.

yaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
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

The default light control is used: when a channel switch is turned on, its corresponding LED lights up.

Configurable Options

Component

unit4relay:
  • id (optional, ID): Sets an ID for the Unit 4Relay component.

Switches

  • relay_1 (optional): Relay switch for channel 1. Defaults to false (off), plus all other Switch options.
  • relay_2 (optional): Relay switch for channel 2. Defaults to false (off), plus all other Switch options.
  • relay_3 (optional): Relay switch for channel 3. Defaults to false (off), plus all other Switch options.
  • relay_4 (optional): Relay switch for channel 4. Defaults to false (off), plus all other Switch options.

3. Reference Example

After adding the device to the Dashboard, you can control the relays in Home Assistant.

Page Tools
PDF
On This Page