PZEM-017 - Daily Energy Reset

I am having a bit of a hard time figuring out how to reset the daily energy consumption on my PZEM-017.

The unit is on slave address 2 and reads all sensor values correctly. I want to reset the daily energy consumption at midnight, each day. Here is what I have:

  uart:
    - id: uart_bus
      tx_pin: 17 # (TX2) - MPPT UART Transmit
      rx_pin: 16 # (RX2) - MPPT UART Receive
      rx_buffer_size: 2048
      baud_rate: 9600
      parity: NONE
      stop_bits: 1
      debug:

    - id: uart_pzem
      tx_pin: 1 # (TX0) - PZEM UART Transmit
      rx_pin: 3 # (RX0) - PZEM UART Receive
      rx_buffer_size: 2048
      baud_rate: 9600
      parity: NONE
      stop_bits: 2
      debug:
  
  modbus:
    uart_id: uart_pzem
    id: modbus_pzem
  
  time:
    - platform: homeassistant
      id: esptime
      on_time:
        - seconds: 0,30
          then:
            - uart.write:
                id: uart_bus
                data: [ 0x01, 0xB3, 0x01, 0x00, 0x00, 0x00, 0x00, 0xB5 ]
        - seconds: 0
          minutes: 0
          hours: 0
          then:
            - pzemdc.reset_energy: pzemdc_1
  sensor:
  - platform: pzemdc
    modbus_id: modbus_pzem
    id: pzemdc_1
    current:
      name: "Solar Load Amps"
    voltage:
      name: "Solar Load Volts"
    power:
      name: "Solar Load Watts"
    energy:
      name: "Solar Load Daily"
      unit_of_measurement: W
      filters:
        - multiply: 1000 #Watts
    update_interval: 30s
    address: 2

The code compiles OK but the daily energy consumption does not reset. Any ideas?

In the time component, two actions are occurring:

  1. data is being read from my solar controller every 30 seconds and
  2. the pzemdc.reset_energy command is being sent at midnight each day. I have tested with this every minute but no joy.

Energy is measured in Wh or kWh not W.

Understood, but the consumption is so small that I need to see it in W in the dashboard. I’ll try changing the units back to kWh and see if that makes a difference.

Update: Who’da thunk it? Not me! LOL
Changing to kWh in unit_of_measurement: did the trick.

Thanks @tom_l

If the number is small use Wh, not W.