True Power higher than Apparent Power (U * I)? (hlw8012 on Neo Coolcam Plug)

I have 2 Neo Coolcam Plugs, both were running tasmota and now I switched to ESPHome.
It’s really great, but one of the plugs has an issue with the current or power sensor.
I have a constant load (ventilator) and tasmota showed:
U = 240 V
I = 0.0052 A
P_true = 10 W
P_apparent = 12.5 VA
Power Factor = 0.8
which are feasible values.

Now with ESPHome this plug shows:
U = 240 V
I = 0.0033 A
P_true = 10 W
P_apparent = 8 VA (calculated U * I)
Power Factor = 1.2 (calculated P_true / (U * I))
Which is physically not possible. P_true can not be higher than (U * I) which means Power Factor is always between 0 and 1.

Can you help me?
BTW: The other plug is on a power supply and shows a power factor of 0.8

My ESPHome config:

substitutions:
  plug_name: esp-sd-2
  # Higher value gives lower watt readout
  current_res: "0.00221"
  # Lower value gives lower voltage readout
  voltage_div: "800"

esphome:
  name: ${plug_name}
  platform: ESP8266
  board: esp8285

wifi:
  ssid: "secret"
  password: "secret"
  use_address: esp-sd-2.fritz.box

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "esp-sd-2 Fallback Hotspot"
    password: "secret"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

web_server:
  port: 80

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO0
      inverted: True
    name: "${plug_name} Button"
    on_press:
      - switch.toggle: relay

switch:
  - platform: gpio
    name: "${plug_name} LED"
    pin: GPIO13
    inverted: True
    restore_mode: ALWAYS_OFF
    id: red_led

  - platform: gpio
    name: "${plug_name} Relais"
    pin: GPIO14
    restore_mode: ALWAYS_ON
    id: relay

    on_turn_on:
      - switch.turn_on: red_led

    on_turn_off:
      - switch.turn_off: red_led

sensor:
  - platform: hlw8012
    sel_pin:
      number: GPIO12
      inverted: True
    cf_pin: GPIO04
    cf1_pin: GPIO05
    current_resistor: ${current_res}
    voltage_divider: ${voltage_div}
    current:
      name: "${plug_name} Strom"
      unit_of_measurement: A
      icon: "mdi:current-ac"
      id: "Strom"
      accuracy_decimals: 3
      filters:
        - or:
          - throttle: 60s
          - delta: 0.01
    voltage:
      name: "${plug_name} Spannung"
      unit_of_measurement: V
      icon: "mdi:current-ac"
      id: "Spannung"
      accuracy_decimals: 0
      filters:
        - or:
          - throttle: 300s
          - delta: 10.0
    power:
      name: "${plug_name} Wirkleistung"
      unit_of_measurement: W
      icon: "mdi:speedometer"
      id: "Wirkleistung"
      accuracy_decimals: 1
      filters:
        - or:
          - throttle: 60s
          - delta: 2.0
    change_mode_every: 6
    update_interval: 5s
  - platform: total_daily_energy
    name: "${plug_name} Stromverbrauch heute"
    power_id: "Wirkleistung"
    filters:
        # Multiplication factor from W to kW is 0.001
        - multiply: 0.001
    unit_of_measurement: kWh
    accuracy_decimals: 3
    icon: "mdi:counter"
  - platform: template
    name: "${plug_name} Leistungsfaktor"
    lambda: |-
      return id(Wirkleistung).state / (id(Spannung).state * id(Strom).state);
    update_interval: 5s
    accuracy_decimals: 2
    unit_of_measurement: "CosPhi"
    icon: "mdi:angle-acute"
    filters:
      - or:
        - throttle: 60s
        - delta: 3.0
  - platform: template
    name: "${plug_name} Scheinleistung"
    lambda: |-
      return id(Spannung).state * id(Strom).state;
    update_interval: 5s
    accuracy_decimals: 1
    unit_of_measurement: "VA"
    icon: "mdi:speedometer"
    filters:
      - or:
        - throttle: 60s
        - delta: 3.0

# Extra sensor to keep track of plug uptime
  - platform: uptime
    name: ${plug_name} Uptime

time:
  - platform: sntp
    id: my_time

I have a theory:
A power supply is a capacitive load = causing the circuit current to lead voltage
An electric motor is an inductive load = causing the circuit current to lag voltage

Maybe there is a bug in the way inductive loads are calculated?

Esphome has an issues tracker.

Thanks for that hint. First, I didn’t think that it’s a bug, I thought I have some mistake in my config.
But I did submit an issue now.

That is why I pointed to the issues tracker :slight_smile:

1 Like

Did you ever resolve/find out more about this? i saw the issue you reported on git has gone stale with no response. i’m getting the exact same behavior as you

No, I gave up on that one and use a ZigBee Plug now

1 Like