esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 34 forks source link

Higher power consumption on power plug than other firmwares #1950

Open hanzoh opened 3 years ago

hanzoh commented 3 years ago

Operating environment/Installation (Hass.io/Docker/pip/etc.):

Docker ESP (ESP32/ESP8266, Board/Sonoff):

platform: ESP8266 board: esp8285 ESPHome version (latest production, beta, dev branch)

1.16.2 Affected component:

n/a

Description of problem: I have flashed a Gosund SP1 plug with esphome and found that it then uses a constant 1.75W by itself, when the relay is on. Then I flashed Tasmota and after that ESPurna on the same plug to compare power usage. Both firmwares use a maximum power of ~1.15W, but they also lower it in between sending updates. The esphome power usage was independent of yaml config, I even reduced it to the bare minimum (see below). The best power consumption was on the original Tuya firmware, they seem to turn stuff off when it is not currently needed.

Problem-relevant YAML-configuration entries:

esphome:
  name: esp01
  platform: ESP8266
  board: esp8285

wifi:
  ssid: "myssid"
  password: "mypassword"

ota:

Logs (if applicable):

n/a

Additional information and things you've tried: n/a

hanzoh commented 3 years ago

I gave up on this plug, because I could not get satisfying results. But when I saw the 1.17 release notes about the new pulse component, I gave it another try. After tuya-converting a fresh plug, I got the same power consumption with esphome as with the other firmwares. Now the plug was disconnected for a couple of days and when I plugged it in again, the same increased power consumption is back. OTA reflash does not help, but flashing Tasmota does. Is there some reserved memory that keeps some (faulty) code which causes this?

rradar commented 3 years ago

Did you try to "play" with wifi power save mode or output power?

power_save_mode (Optional, string): The power save mode for the WiFi interface. See Power Save Mode

output_power (Optional, string): The amount of TX power for the WiFi interface from 10dB to 20.5dB. Default for ESP8266 is 20dB, 20.5dB might cause unexpected restarts.

https://esphome.io/components/wifi.html

hanzoh commented 3 years ago

Yes, setting power save mode to LIGHT lowers the power consumption in both cases (normal and too-high power consumption) by about 0.3W.

I can now reproduce the too-high state like this:

hanzoh commented 3 years ago

I finally found the issue. I have added switches for every GPIO in yaml and set them to restore_mode: ALWAYS_OFF. After a power cycle the power consumption stays at 0.6W, just as expected and what is also happening with Tasmota et al. I then turned the switches on, one by one, and GPIO15 was the culprit: Once I switched that on, power consumption went up to 1.0W. The odd thing is: there is nothing connected to that.

So why does esphome enable this pin after a cold reboot, while Tasmota and ESPurna do not?

rradar commented 3 years ago

The odd thing is: there is nothing connected to that.

Would be interesting if this behavior could be reproduced on another device :thinking:

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

hanzoh commented 2 years ago

I can still reproduce this on all four of my Gosund SP1 plugs.

JamesSwift commented 2 years ago

Could you share your config for this?

I'm using

switch:
  - platform: gpio
    pin: GPIO15
    restore_mode: ALWAYS_OFF
    id: pin15
hanzoh commented 2 years ago

Sure:

substitutions:
  plug_name: plug-media-center
  plug_name_friendly: "Media Center"
  pulse_factor: "0.0286"
  relay_mode: ALWAYS_ON

external_components:
  - source:
      type: local
      path: my_components
    components: [ pulse_meter ]

esphome:
  name: ${plug_name}

esp8266:
  board: esp8285

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

logger:

api:
  password: !secret api_password

ota:
  password: !secret ota_password

time:
  - platform: homeassistant

sensor:
  - platform: pulse_meter
    pin: GPIO4
    name: "${plug_name_friendly} Power"
    internal_filter: 0us
    timeout: 10s
    device_class: "power"
    unit_of_measurement: 'W'
    accuracy_decimals: 1
    filters:
      - multiply: ${pulse_factor} # Pulse to Watt
      - throttle: 10s
    total:
      name: "${plug_name_friendly} Energy"
      device_class: "energy"
      state_class: "total_increasing"
      unit_of_measurement: "kWh"
      accuracy_decimals: 1
      filters:
        - multiply: ${pulse_factor} # Pulse to Watt
        - multiply: 0.0167 # Minutes to Hours
        - multiply: 0.001  # Watt to Kilowatt
        - throttle: 60s

binary_sensor:
  # Binary sensor for the button press
  - platform: gpio
    id: button
    pin:
      number: GPIO3
      inverted: true
    on_press:
      - switch.toggle: relay

switch:
  # Switch to toggle the relay
  - platform: gpio
    id: relay
    name: "${plug_name_friendly}"
    pin: GPIO14
    restore_mode: ${relay_mode}
    on_turn_on:
      - light.turn_on: led
    on_turn_off:
      - light.turn_off: led
  # Turn CF1 off, as current and voltage are not monitored
  - platform: gpio
    id: gpio5
    pin: GPIO5
    restore_mode: ALWAYS_OFF
  # Turn SEL off, as current and voltage are not monitored
  - platform: gpio
    id: gpio12
    pin: GPIO12
    restore_mode: ALWAYS_OFF
  # Force GPIO15 off to save ~350mW
  - platform: gpio
    id: gpio15
    pin: GPIO15
    restore_mode: ALWAYS_OFF

output:
  # Blue LED for Relay state
  - platform: esp8266_pwm
    id: state_led
    pin:
      number: GPIO1
      inverted: true

light:
  # Relay state light
  - platform: monochromatic
    output: state_led
    id: led
    restore_mode: ${relay_mode}

# Uses the red LED as a status indicator
status_led:
  pin:
    number: GPIO13
    inverted: true
Fma965 commented 2 years ago

FWIW i can replicate the same thing on a UP111, this should be added to the config as forcing GPIO15 to off works great, from 1w to 0.7w and less heat

twasilczyk commented 7 months ago

I reproduced this problem and a fix on Gosund WP5.

I tried:

And none of this made any noticeable difference - I had two plugs next to each other (one with stock firmware and one with esphome), both with relay turned off. Stock was at room temperature, while ESPHome was noticeably warm to the touch.

After setting GPIO15 restore_mode: ALWAYS_OFF it's back at the room temperature (and still works as expected).

It makes sense - floating GPIO is a common power draw waste. I think ESPHome should just take care of all unused GPIO on a given MCU. Not necessarily through restore_mode (because this could make problems if the pin is electrically connected somewhere), but setting as input and enabling pull up/down resistor should be okay.

twasilczyk commented 7 months ago

I can confirm setting all GPIOs as pull-up/down inputs saves about 0.45W for Gosund WP5.

On the other hand, setting power_save_mode and output_power for Wi-Fi makes no measureable difference.