Energy consumption and Arlec Grid Connect (Tuya) smart plug

I got a Series 2 Arlec Smart Plug with Energy Metering flashed with ESPHome.

My notes:

Product Name: Arlec White Grid Connect Smart Plug in Socket with Energy Meter
Product Code: PC191HA (White) & PC191BKHA (Black). “Series 2” (CB2S module, BK7231N chip)

Product Listing:

  1. White
  2. Black

Cloudcutter Guide Followed: UPDATED How To Guide - Tuya CloudCutter with ESPHome LibreTiny - No soldering | digiblurDIY
LibreTiny Support: CB2S - LibreTiny
LibreTiny Profile (Initial flash): UPK2ESPHome

Initial Impressions:

Pro’s:

  • ESPHome-able (via Cloudcutter and LibreTiny). No need to open to flash.
  • Small form factor (fit 2 side-by-side :white_check_mark:)
  • Power Monitoring
  • I like the button being on the top for access
  • Oz Certified (as opposed to the Athom I moved over to after the Kogan’s and Brilliant’s failed)
  • Dirt cheap at $15 AUD.

Con’s:

  • Possibly “disposable devices” - who knows how long they will last? Based on other cheap devices, maybe not that long. Caps are a common culprit.
  • The end to end flash pipeline is still a little involved even though it’s wireless. Expect a Tuya convert style flash. The instructions are pretty good. When I hit issues it was mainly because I wasn’t following them properly :wink:. After you’ve done one it would be way faster for subsequent devices.

TODO:

  1. More testing
  2. Optimise config.
  3. Long term review

Initial config is below. I copied / merged some stuff from the Athom config and bits from Don too.

# Config for Arlec White Grid Connect Smart Plug in Socket with Energy Meter 
# Product Code: PC191HA (White) & PC191BKHA (Black). “Series 2” (CB2S module, BK7231N chip)
# https://www.bunnings.com.au/arlec-white-grid-connect-smart-plug-in-socket-with-energy-meter_p0273367
# https://upk.libretiny.eu/?profile=arlec-pc191ha-smart-plug-bk7231n-v1.1.8
# Copied some config from Athom: https://github.com/athom-tech/athom-configs/blob/main/athom-smart-plug-v2.yaml

substitutions:
  relay_restore_mode: RESTORE_DEFAULT_OFF         #Adjust as required.
  hlw8012_update_interval: 10s                    #Not sure how this affects lifetime and maybe overheating? 
  
esphome:
  name: arlec-smartplug-1
  friendly_name: Arlec Smartplug 1
  comment: "Arlec Black Grid Connect Smart Plug in Socket with Energy Meter"  
bk72xx:
  board: generic-bk7231n-qfn32-tuya #https://docs.libretiny.eu/boards/cb2s/  
  
wifi:
  ap:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.1.80
    gateway: 192.168.1.1
    subnet: 255.255.255.0
    

logger:
mdns:
api:
  password: ""
ota:
  password: ""

globals:
  - id: total_energy
    type: float
    restore_value: yes
    initial_value: '0.0'
  
sensor:
  - platform: uptime
    name: Uptime
  - platform: wifi_signal
    name: "WiFi Signal"
    update_interval: 60s
    
  - platform: hlw8012
    model: BL0937
    update_interval: ${hlw8012_update_interval}
    change_mode_every: 3
    voltage_divider: 770 #Required changing
    current_resistor: 0.001 ohm
    cf_pin:
      number: P8
      inverted: true
    cf1_pin:
      number: P7
      inverted: true
    sel_pin:
      number: P6
      inverted: true
    current:
      name: Current
      filters:
        - multiply: 0.4250 #https://community.home-assistant.io/t/esphome-install-does-not-update-firmware/544026/10?u=mahko_mahko
        - lambda: if (x < 0.01) {return 0;} else {return x;}
    voltage:
      name: Voltage
    power:
      name: Power
      id: power_sensor
      filters:
        - multiply: 0.97
        - lambda: if (x < 0.01) {return 0;} else {return x;}
    energy:
      name: Energy
      id: energy
      unit_of_measurement: kWh
      filters:
        - multiply: 0.001  # Multiplication factor from W to kW is 0.001
      on_value:
        then:
          - lambda: |-
              static float previous_energy_value = 0.0;
              float current_energy_value = id(energy).state;
              id(total_energy) += current_energy_value - previous_energy_value;
              previous_energy_value = current_energy_value;
              
  - platform: template
    name: "Total Energy"
    unit_of_measurement: kWh
    device_class: "energy"
    state_class: "total_increasing"
    icon: "mdi:lightning-bolt"
    accuracy_decimals: 3
    lambda: |-
      return id(total_energy);
    update_interval: ${hlw8012_update_interval}
    
  - platform: total_daily_energy
    name: "Total Daily Energy"
    restore: true
    power_id: power_sensor
    unit_of_measurement: kWh
    accuracy_decimals: 3
    filters:
      - multiply: 0.001
    
output:
  - platform: libretiny_pwm
    id: output_led_1
    pin:
      number: P23
      inverted: true

light:
  - platform: monochromatic
    id: light_switch_1
    output: output_led_1

binary_sensor:
  - platform: gpio
    id: binary_switch_1
    pin:
      number: P10
      inverted: true
      mode: INPUT_PULLUP
    on_multi_click:
      - timing:
          - ON for at most 1s
          - OFF for at least 0.2s
        then:
          - switch.toggle: switch_1
      - timing:
          - ON for at least 4s
        then:
          - button.press: Reset

switch:
  - platform: gpio
    id: switch_1
    name: Relay 1
    pin: P24
    on_turn_on:
      - light.turn_on: light_switch_1
    on_turn_off:
      - light.turn_off: light_switch_1
    restore_mode: ${relay_restore_mode}

status_led:
  pin:
    number: P26
    inverted: true
    
text_sensor:
  - platform: libretiny
    version:
      name: LibreTiny Version
  - platform: wifi_info
    ip_address:
      name: "IP Address"
    ssid:
      name: "Connected SSID"
    mac_address:
      name: "Mac Address"
      
button:
  - platform: factory_reset
    name: "Restart with Factory Default Settings"
    id: Reset

  - platform: safe_mode
    name: "Safe Mode"
    internal: false
    
time:
  - platform: sntp
    id: sntp_time
6 Likes