esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
293 stars 36 forks source link

How to reset total energy value on PZEM-004T V1 (version with 8-segment screens) ? #5368

Open Dim3333 opened 10 months ago

Dim3333 commented 10 months ago

The problem

Hi,

How to reset total energy value on PZEM-004T V1 (8S) ? https://esphome.io/components/sensor/pzem004t.html?highlight=pzem

My code:

esphome:
  name: wattmetre
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: "***********"
  password: "***********"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Wattmetre Fallback Hotspot"
    password: "**********"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

web_server:
  port: 80

# Example configuration entry
uart:
  tx_pin: D6
  rx_pin: D7
  baud_rate: 9600
  stop_bits: 1

sensor:
  - platform: pzem004t
    current:
      name: "PZEM-004T Courant"
    voltage:
      name: "PZEM-004T Tension"
    power:
      name: "PZEM-004T Puissance"
    energy:
      name: "PZEM-004T Energie"
    update_interval: 10s

# Temps de fonctionnement
  - platform: uptime
    name: "Allumé depuis (s)"
    id: uptime_sec

  - platform: wifi_signal
    name: "Puissance Signal WiFi"
    update_interval: 60s

text_sensor:
  - platform: version
    name: "Version ESPHome"
  - platform: template
    name: "Allumé depuis (j)"
    lambda: |-
          int seconds = (id(uptime_sec).state);
          int days = seconds / (24 * 3600);
          seconds = seconds % (24 * 3600); 
          int hours = seconds / 3600;
          seconds = seconds % 3600;
          int minutes = seconds /  60;
          seconds = seconds % 60;
          return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
    icon: mdi:clock-start
    update_interval: 60s

switch:
  - platform: restart
    name: "Redemarrage Wattmetre"

  - platform: uart
    name: "PZEM-004T Energy Reset"
    data: [0x01, 0x42, 0x80, 0x11]

binary_sensor:
  - platform: status
    name: "Etat du Wattmetre"

Thanks for your support.

Which version of ESPHome has the issue?

2023.12.5

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2024.1.2

What platform are you using?

ESP8266

Board

No response

Component causing the issue

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

github-actions[bot] commented 6 months 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.