Calculate sum of kWh value on specific day

Hi, I have one washing machine that need to calculate the sum of kWh on specific day of the month which is Sunday only. As the washing machine is share by 2 person, one person use the washing machine on Sunday only while the other will use it on other day.

I just want to calculate each person kWh consumption. The machine did plug in to the smart plug which will generate kWh value in realtime.

To calculate person A which use machine on Sunday only, I just need to sum up all Sunday kWh of the month. Possible to have each Sunday kWh value store on somewhere else?

To calculate person B, I just need sum of washing machine kWh of that month which I already have then minus person A kWh.

Create a utility meter with two tariffs. “Sunday” and “not Sunday”.

    source: sensor.smartplug_energy  ## change this to your sensor ##
    name: Washer Energy
    cycle: monthly
      - sunday
      - not_sunday

Switch the tariffs using an automation with a time trigger.

  - platform: time
    at: "00:00:00"
  - if:
      - condition: template
        value_template: "{{ now().weekday() == 6 }}"   
      - service: select.select_option # Sunday
          entity_id: select.washer_energy
          option: sunday
      - service: select.select_option  # Rest of the week
          entity_id: select.washer_energy
          option: not_sunday

This will create two sensors, sensor.washer_energy_sunday and sensor.washer_energy_not_sunday that will count the energy used on Sunday and the rest of the week respectively. Both will reset on the 1st day of every month.

1 Like

Thanks for fast response, that utility meter need to create in configuration.yaml? if I want to reset it every 20th of the month, I just need replace the “cycle: monthly” to "cron: “0 21 * * *” " ? possible to pull each day kWh value from the “sensor.washer_energy_not_sunday” if want see the value?

No, you can do it in the UI Helpers section. I would advise you to use yaml though if you can. I’ve seen issues reconfiguring utility meters created in the UI. If you feel you will never change it then the UI should be ok.

Not quite. That cron pattern would be at 9pm on every day. Use 0 0 21 * *, this resets at 0:00 on the 21st of every month.

Yes, create another utility meter and feed it your not sunday sensor with a daily cycle:

    source: sensor.washer_energy_not_sunday
    name: Daily Washer Energy, Not Sunday
    cycle: daily

This will create the sensor: sensor.washer_energy_daily_not_sunday that resets every day and will not count energy on Sundays.

1 Like

just tested & I really appreciate it, working perfectly !! Thanks again :slight_smile:

1 Like