This tutorial will introduce how to use the Atom Socket smart outlet integrated into Home Assistant to achieve switch control and energy monitoring.
This tutorial uses ESPHome 2025.12.5 to compile and upload firmware. If you encounter compilation/upload issues, please consider switching the ESPHome version.
Create a new device. Click the green button in the lower-right corner to create the device.

Create device name.
2.1 Click CONTINUE.
2.2 Click New Device Setup.
2.3 Enter the device name, then click NEXT.

Select device type.
3.1 Click ESP32.
3.2 Click SKIP.

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

The following is the core part of the code, along with relevant references and instructions.
Add uart component:
uart:
rx_pin: GPIO22
baud_rate: 4800
parity: EVEN 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 Add Switch component:
switch:
- platform: gpio
name: "Atom Socket"
pin:
number: GPIO23
inverted: False
restore_mode: ALWAYS_ON After making changes, click SAVE and INSTALL in the upper-right corner, then select Manual Download in the pop-up window.

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

Connect the device to your host via a USB Type-C data cable. Open ESPHome Web and click CONNECT to connect to the device.

Find the corresponding serial port number.

Click INSTALL.

Select the previously compiled firmware to upload.

After the flashing is complete, restart the device.
In Home Assistant, click Settings > Devices & Services to enter the integration management page.

Click Add to integrate the device into Home Assistant.

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

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