English
English
简体中文
日本語

Atom Socket Home Assistant Integration

This tutorial will introduce how to use the Atom Socket smart outlet integrated into Home Assistant to achieve switch control and energy monitoring.

1. Preparation

Environment Setup

  1. Refer to the official Home Assistant documentation to install Home Assistant.
  2. Refer to the official ESPHome documentation to install the ESPHome Device Builder add-on. (Note: This tutorial is based on ESPHome 2025.12.5. If compilation errors occur, switch to this version for verification.)

Hardware Products

2. Online Flashing

Click the Online Flashing button below and follow the prompts to flash the firmware and configure Wi-Fi, allowing you to quickly connect Atom Socket to Home Assistant.

For detailed flashing and configuration instructions, refer to Online ESPHome Firmware Flashing and Configuration.

After using online flashing, you do not need to perform the "Firmware Compilation & Flashing" steps. Proceed directly to 4. Getting Started.

3. Firmware Compilation & Flashing

This section explains how to recompile the project from the yaml configuration file for secondary development, feature modifications, or new functionality.

Compilation Time
The first compilation may take some time, depending on the performance of the Home Assistant host and network quality.

Create Device

  1. Create a new device. Click the green button in the lower-right corner to create the device.

  2. Create device name.

    2.1 Click CONTINUE.

    2.2 Click New Device Setup.

    2.3 Enter the device name, then click NEXT.

  3. Select device type.

    3.1 Click ESP32.

    3.2 Click SKIP.

  4. Start editing the YAML file. Click EDIT. We can customize device functions through the YAML file.

Modify Configuration

The following is the core part of the code, along with relevant references and instructions.

UART Configuration

Add uart component:

uart:
  rx_pin: GPIO22
  baud_rate: 4800
  parity: EVEN

Sensor Configuration

Add Sensor component:

The main chip module is the HLW8032 energy metering chip, which is responsible for collecting and reading sensor data such as voltage, current, and power.

sensor:
  - platform: hlw8032
    voltage:
      name: HLW8032 Voltage
      id: hlw8032_voltage
    current:
      name: HLW8032 Current
      id: hlw8032_current
    power:
      name: HLW8032 Power
      id: hlw8032_power
    apparent_power:
      name: HLW8032 Apparent Power
      id: hlw8032_apparent_power
    power_factor:
      name: HLW8032 Power Factor
      id: hlw8032_power_factor

Switch Configuration

Add Switch component:

switch:
  - platform: gpio
    name: "Atom Socket"
    pin:
      number: GPIO23
      inverted: False
    restore_mode: ALWAYS_ON

Download and Flash Firmware

  1. After making changes, click SAVE and INSTALL in the upper-right corner, then select Manual download in the pop-up window.

  2. Once the firmware compilation is complete, click Download and select Factory format (Previously Modern).

    Note
    Click Atom Socket to view the complete example configuration.
  3. Connect the device to your host via a USB Type-C data cable. Open ESPHome Web and click CONNECT to connect to the device.

  4. Find the corresponding serial port number.

  5. Click INSTALL.

  6. Select the previously compiled firmware to upload.

  7. After the flashing is complete, restart the device.

4. Getting Started

  1. In Home Assistant, click Settings > Devices & Services to enter the integration management page.

  2. Click Add to integrate the device into Home Assistant.

  3. After adding the device, the data will be displayed correctly.

  4. Finally, we add these entities to the dashboard; the following shows their display results.

    Note
    HLW8032 Apparent Power and HLW8032 Power will only display data when the relay switch is turned on.

5. Video

Page Tools
PDF
On This Page