Sonoff POW R2 - how to know how I consumed in a day or month

Hi,
I could say you are really not far away :slight_smile:
I also wanted to know info for last month and etc. I| just added a little calculations for what day of month is today. So my code is:

sensor:
- platform: template
  sensors:
    # energy_usage:
      # friendly_name: "Energijos sąnaudos"
      # device_class: power
      # value_template: "{{ state_attr('switch.sonoff_powermeter', 'power') }}"
  

  
    today_consumption:
      friendly_name: "Šiandien"
      device_class: power
      unit_of_measurement: kwh
      value_template: "{{ state_attr('switch.sonoff_powermeter', 'consumption')[0] }}"
    
    
    yesterday_consumption:
      friendly_name: "Vakar"
      device_class: power
      unit_of_measurement: kwh
      value_template: "{{ state_attr('switch.sonoff_powermeter', 'consumption')[1] }}"
    
    this_week_consumption:
      friendly_name: "Einamoji savaitė"
      device_class: power
      unit_of_measurement: kwh
      value_template: "
        {% set p=state_attr('switch.sonoff_powermeter', 'consumption') %}
        {% set days=now().weekday()+1 %}
        {{ p[1:(days)]|sum if p }}"
        
    this_month_consumption:
      friendly_name: "Einamasis mėnuo"
      device_class: power
      unit_of_measurement: kwh
      value_template: "
        {% set p=state_attr('switch.sonoff_powermeter', 'consumption') %}
        {% set days=now().day %}
        {{ (p[1:(days)]| sum if p )|round(2) }}"
1 Like

Thank You, I used Your code to have paticular month in total, instead of last 30 days which is not so important for me.

However one small tip - if You really want to have current month in total You need to edit last line from

{{ p[1:(days)]|sum if p }}"

to

{{ p[0:(days)]|sum if p }}"

Without that You only have current month until yesterday. This array starts from 0.

You are welcome.
I know about day count, It was done on purpose.

Hi
I tried your code and it created the entity but unfortunately the values are always 0.
do I need to so something else somewhere else?
Kind Regards

it is easier now actually. Sonoff pow used to have a service called “consumption”…and you just had to do the math to get the daily, monthly usage, etc. Now, this service no longer exists, but now there´s a new entity “ENERGY” … you just have to add it to your energy panel… I do not like to use this energy panel, and I’m still trying to figure out how to generate an entity from this panel to get a regular entity to use in my dashboards…(energy panel could generate a month entity, instead of we have to create an entity using utility meter)

no more consumption service


new energy entity

entity added to the energy panel

Usage (energy panel)

For the month’s usage, you have to create a utility helper, using “helpers”

and then, u do the math to know how much u r spending monthly, in case u don’t wanna use the energy panel (month sensor x counter)

image

If there is any easier way, I don’t know…this is how I do it.

2 Likes

Many thanks for your quick reply.
unfortunately is energy not enabled on mine :frowning:
I had to create a helper to get a result.

the entity energy does not come enabled by default…u gotta do it yourself,…pretty easy…

it comes like this…

try there and tell me if u succeeded.

6 Likes

oops, sorry to bother you with so stupid questions.
works great for me
many thanks for your kindness and support
have a nice day
cheers
alex

Hi!

I have two separate phases coming to my house, one for the 2 ACs, and the other for all other devices. (The reason for this, that here we have a special price for AC heating for the winter, if you are using this kind of energy with AC higher SCOP rates)

So originally my idea was to use a Shelly EM with two 50A clamp, but it turned out, that Shelly EM cannot measure energy on a different phase - so its not working with one ShellyEM for two phases.

When the AC was set up 2 years ago, I’ve added two Sonoff POW2 for each AC, after the breaker, so I have measurement for the ACs already, but as it did not provided energy entity, I could not use it.
Now I would like to measure the ACs with Sonoff, and the other phase with Shelly, and I’m fine with the Energy dashboard as a beginning.

I was so happy that I found your topic, and I could enable the Energy entity on the Sonoff integration, but it says ‘Unknown’, and no any value in it.
What did I get wrong? Do I need to wait?

Regards,

Szabolcs

Screenshot 2022-11-11 at 12.43.50

I’m in the same situation. Did you find a solution?
Thanks and regards

Same with me. I think it might be a firmware thing though. Had my POWR320D set up and working, and I am pretty sure there was a value there. But device had FW update, so I did that (on version 1.0.7 now) and now my Energy is also not showing up. So might be FW.

alguma novidade?

Just use Utility Meter