Graphing Energy

image

type: custom:mini-graph-card
entities:
  - sensor.cleargrass_1_temp
show:
  labels: true
  average: true
  extrema: true
style: |
  ha-card .header.flex .name.flex .ellipsis {
    color: green;
    font-weight: 100;
  }
  ha-card .header.flex .icon {
    color: red;
  }

Do not guess. Use what is specified in docs.
https://www.w3schools.com/cssref/pr_font_weight.asp

Cannot tell you unfortunately.
My advice - ask about conversion in a separate thread, it requires using jinjia2 skills or something similar…

1 Like

Thanks a lot , that 100 to 900 scale is really nice to play with to get a nice layout without the typical black and with bold or normal. Like it a lot.

But there are 2 other points I do not get right: the figure has become white, the unit stays in the primary color of user settings I guess

image

And then this is not working cause the weight stays the same and the white is not a real white if you look carefully

  ha-card .header.flex .name.flex {
    color: white;
    font-weight: 100;
    font-size: 24px;
  }

as you can see here where it looks “dirty” not white.
image

I hope to get rid of these format issues soon like here the dot instead of a comma but I guess that will need a hard core replace “.” by “,”

By default colors of value & unit are different - remove all styles and you can see it.

To manage colors, use "card-mod":

style: |
  ha-card .states.flex .state .state__value.ellipsis {
    color: orange;
  }
  ha-card .states.flex .state .state__uom.ellipsis {
    color: cyan;
  }

image

Regarding number format - check these settings, MAY BE they are supported by mini-graph-card:
image

1 Like

I tried and it worked like before which means it did not work out like expected.

The title line / header as the unit do not really “accept” these colours fully cause they get darker. The figure is pure white as expected, the unit ‘kg’ and title above do get a shadowed white or so.

After all same result as before - deleting the other lines did not change anything.

And of cause I have used the custom / user settings cause the internal HA cards do work well only all the custom cards seem to miss the number format support.
The only way around would be adding this

style: |
  ha-card .states.flex::after {
    color: white;
    font-weight: 400;
    font-size: 24px;
    content: "GRUNDUMSATZ:\A {{ states('sensor.scale_3_basal_metabolism') | round(1) | replace(".","%") | replace(",",".") | replace("%",",")  }} kcal\A BMI: {{states('sensor.scale_2_bmi')}}";
    white-space: pre;
    background-color: rgba(50,50,850,0.9);
    padding: 5px 5px 5px 5px;
    border-radius: 5px;
  }

But a lot will complain about that - even though I do not have any other solution to get a simple “#.##0,0” european decimal format.

thanks a lot

As having said I do no longer use SonOff products cause their measurements where too far off back in 2019 when I had gotten the first batch.

I do not know why you did not read the infos available on github and use such data that you had provided here.
Life would be a lot easier for you to do things carefully with full attention cause you simply missed all that what is important in that link. I had stopped using SonOff products due to bad performance or bad measurements as I had told you 2 years ago but at least I read your comment and the link carefully. And if you own a SonOff POW there is a simple method to learn what this integration can offer for your particular POW.

CTRL + ‘f’
where you type in POW and will get hopefully results.

Just from that screenshot you get a lot: 25 hits and the first one sounds really serious like POW refresh intervalls for accuracy

Then there is even a list of tested devices ( I have had POW R2 version or 2nd release)

There is also a lot to read about the different modes supported with and without cloud you should have read carefully to make the right decision cause in a hurry you will might miss again the basics as before cause other wise you would not have asked all those questions which have been answered by the ressource you had provided, not we here or I.

And at least I have read those stuff from the birds eye perspective even though I have HA just for 4 weeks running and left the SonOff ship back in 2019.

You will find in the link you had provided even all the answers for your questions with the basic CTRL + f search cause hit number 21 on that page talks about Pow Power consumption and its services, which can count locally up to 100 days of power consumption (according to this docs - but you have to check if those are different for different versions of that POW)

And there is also the setup described as “use automation” and the sensor creation which at least mentions the daily consumption and 10 day consumption

Finally do not forget to take your time and do not things in a rush on the hunt for fast success cause otherwise you might miss important lessons as I had mentioned before which i had called for the tuya world ‘sampling_size’ and is described here, but in a kind of different issue that can cause issues in your environment but not in every environment which seems to have been fixed too.

I hope that all other that are on the search for a serious solution to visualize energy consumption over time will come across this topic and learn the basics that way instead of going on the hunt for copy and paste success.

The SonoffLAN integration delivers that sensor needed for a visualisation that mini graph provides … but that sensor is the manufacturers own secret how he is doing the measurement of Wh and what kind of riemann integral he is using cause you have to trust EWE totally while the other way I had described would give you the chance to proof all the details by simply measuring the Watts on your own and if your Wattmeter claims 80W and the sonOff sensor also sends a 79,9 W figure you know the deviation of that unit.

And from there on you are the master by using the Riemann integral to get your energy consumption right … or as right as you can with low deviation - or you use the blackbox sensor of the manufacturer which does the math for you (measuring the Watts used in every second and of cause adding those consumption figures of every second up cause a 3600 W hair dryer burns 1 Wh in every second on full power).

I like to understand the things and to know who will be responsible for what. If you will use the simple Wh sensor provided by EWE you will stuck with all those risks but also can benefit in case your HA integtration might suck and miss to measure cause the onboard counter of each POW will continue to count even if you HA has died meanwhile.

Up to you to go the easy convenient copy cat road or to understand and measure things.

1 Like

Thanks for the detailed response. I did read that thoroughly but was trying to deal with SSL issue, since I have enabled SSL I can’t access Homeassistant on the Android app.
To keep it relevant, how do I plot the consumption data shown in the screenshot in mini-graph?

Are you kidding ?
4 days ago you did knew what to do


you had showed us these aquarium screenshots

And now after you had found out your sensor you have lost how to get a chart of such sensors values ?
I mean you had gotten all the replies needed and even how to create a template sensor which is all what you need. Again a successfull Copy and Paste hunt might be fine but does not really bring you any benefit cause if you had learned at least a tiny bit then you would have asked other questions how or why your sensors are totally off as I had warned you the whole time: understand the whole thing like how a riemann integral works and what it is needed for instead of hunting for a polished curve of doubtful quality / message.

It might be time to take things seriously and do some math first otherwise you will rely on figures that are wrong and you will plot a dream world but not reality.

Watt = Volt x Ampere

that is the usual equation and if I take your figures from your 3 graphs even you should get doubts 233,97 V x 0,31 A = 72,53 W

while your graph called W had shown a nice 43,7 W figure. Pretty much off.

And even your latest sensor values are painting a similiar picture
235,99 V x 0,49 A = 115,64 W but your sensor reports 70,5 W
image

Do you really need a nice looking polished graph of pure guesswork or something serious?
The consumption figures are a result of Watt over time but if the Watt figure is doubtfull the Wh consumption can not be less doubtfull regardless which card you choose.
And the mini graph card just simply needs a working sensor to plot a graph, such one you had plotted in the beginning called ‘aquarium’.

Here is a graph of an hourly consumption report of a plug that is working right and showed a 24 h consumption between 0 Wh and 50 Wh - of cause per hour, so 0 - 50 W range.
image
And such graph can be developed from your aquarium graph or any other temperature sensor or any other example mentioned before and shown on that page.
The mini graph card is doing its job right … once you deliver the right input.

sorry too late, cause I was writing a reply when you were writing your.
This time he had asked about the mini graph card so it was no longer off topic as you had mentioned cause he had asked how to plot that sensor .

1 Like

I am using Sonoff POW2 to measure Voltage, Current and Power. I can display all these values in a mini-graph easily. How do I chart energy consumption and power used? It will require math calculations.

If you have sensors with all necessary data you may use mini-graph-card. There are examples for power consumption here. You can also use “group_by” option.

You may define template sensors for this and keep using mini-graph-card.

any links to the former and how do I define template sensors?

sorry,
but first you need to do basics.
And voltage current are not needed if you have already power or Watts.

If you have those you have to do the math first, which means power x time or watts x hours and that is achieved by the riemann integration that is supported by HA . But that is something way of this topic and will lead to further questions like energy countes, resets, sampling size and so on

Get the data first and then you can decide about graphs not vice versa.

that is the point I am struggling with right now.

I can group my weekly counters by date but that will only show me daily increasing bar even though I need a grouping based on weeks or months.

But the only option mentioned that might fit is called “interval” but without any example on github nor here and even google did not find an example for interval and how to use it for grouping by week or month.

But maybe you have an idea for that issue here
image

created by this

type: 'custom:mini-graph-card'
name: COUCH
smoothing: false
hours_to_show: 336
points_per_hour: 1
line_width: 2
line_color: orange
animate: true
height: 80
entities:
  - sensor.kwh_2_3_weekly
font_size: 70
show:
  graph: bar
  points: true
  icon: false
  labels: true
  name: true
group_by: date
aggregate_func: max
decimals: 3
lower_bound: 0
upper_bound: 2

On github I foud that group_by: date can also be hour or interval but not how or where is inverval can be defined ?

Thx for your support.

1 Like

@
typxxi
Never mind. Found the sensor after a restart and waiting for 5 hours. It was located under as

sensor.today_consumption

and

sensor.ten_days_consumption

Actually found it accidentally while adding a graph. I am just getting my feet wet using sonoff, but will obviously try to find some calibrated energy meter and shelly devices.

@tom_l please move all relevant discussion here. So that any future user can easily follow our discussion.

Isn’t AC power slightly different from DC power? Power in AC Circuits

I am not sure at all cause this is now a POW R2 - at least the second release we had gotten back then to measure solarroof production where it was working right while the first was not really working.

I am not sure if a shelly would really help a lot or a tuya might be better cause cheaper and everywhere available but the SonOff figures are looking like a lottery or gamble.
224 Volt x 0,51 A must end at least in a 112 Watt figure, for sure not in 70,6 W unless there would be something going on what we know from DC as pwm.

You simply need to measure Voltage and I guess that this figure will be quite right .
The second point will be the current. Both can be achieved by a multimeter easily but it does not really help cause you might only need the right calibration.

That power meter will deliver a Wh measurement that you can crosscheck first by measuring a device you can be sure that it has such power consumption like an old OSRAM bulb with 80W or so. After running such a bulb for a quarter hour you should see a 20,x Wh figure just to make sure what your power meter is measuring. All claim to be accurate but it needs a proof like this or a water kettle running 6 minutes with its 2000W which will mean 6 / 60 hours x 2000 W = 1 / 10 x 2000 Wh = 200 Wh

And from there on you can then start to measure what the aquarium socket will use in parallel while the SonOff plug is plugged into that device and reports its own figures.

You can then compare live figures in the sensor pane with the figures of such power meter and I hope you will get a kind of constant factor as deviation.

The black box for you is the algorithm the sonoff sensor uses for the Wh calculation locally and how accurate this is.

I would try to get my own Watt calculation and let the rieman integrall do the math or measurement over time better known as consumption. And this figure can be compared with the power energy meter.

Cause such aquarium would here be called a power or energy monster considering the 110 W power in a 247 use case which would simply mean roughly factor 9 to get the annual kWh consumption: 990 kWh p.a.

that would cause a 300€ bill here … or a third of a ususal house hold consumption of 2,x persons

And therefore it is more important to get this figure right than what most of our 10 plugs measure which are about 100 - 300 kWh a year except that one that powers the EV with usually 2,3 kW

At least you seem to have the pow2 type as the sensor says which was far more accurate than the previous version cause we had back then both types in use.

The longer you check your values the more questions might occure cause the 4,47 kWh figure for 10 days does not really fit to the sensor screenshot where you could see a most likely daily consumption of 0,94 kWh - 0,87 kWh per day or roughly 4 kWh in 4 days.

What do you power through that POW R2 ?
a pump and a water heating / cooling … if so then that would show a smaller constant consumption for the 247 running pump while the heating or cooling would kick in only from time to time which would show a different pattern like a fridge.

But there is a huge gap between the Watts in your screenshot and the consumption except you would always have created a screenshot during heating / cooling phase cause based on the watts calculated by Volt x Ampere = 112 W over 24 hours the consumption would be a lot higher than just ~ 1 kWh as the sensor had shown.

Here you can get ELV energy master basic that will measure the figures quite accurate but I guess that his energy meter is product you might only get in the EU.
My tuya base figures like V and A do not fit together too but at least the W are right and Watts over Riemann integral deliver a figure which is 100,5% of the power meter figure so the HA reported consumption is about 0,5% higher.

Maybe you find a different device where you can start easier than such a combined use case where at least 2 or more consumers are powered through the POW R2 I guess cause an aquarium usually needs light, warm and a water pump which are running independently and at least warm is controlled by sensor I guess, while light might be running in a time schedule and water pump too or even constantly.

I would try to measure 1 device at a time like that bulb just to get behind what values might be right and what are wrong. It took me back then about 2 months to get behind that whole mess how far off these plugs can be till I found the tuya being accurate and also across the batch in a usual use case where max. 1000 Watt consumers turn on / off cause in spikey use cases the accuracies goes down too, I mean a lot of 1000 W on / off switches per day you usually find when micro waves are running a programm of heating rice.

I was able to add Sonoff Pow2 using Alexxit’s SonoffLan control to Energy dashboard Orginal idea presented here Integration Solar inverter huawei 2000L - #587 by bigcheese GitHub - AlexxIT/SonoffLAN: Control Sonoff Devices with eWeLink (original) firmware over LAN and/or Cloud from Home Assistant
Steps are simple

  1. configuration
  2. Scroll down to Customizations
  3. select your entity
  4. select device class as “energy”
  5. select state class as " measurement"
  6. Select other
  7. Attribute name “last_reset”
    8 attribute value “1970-01-01T00:00:00+00:00”
  8. click save
  9. Now your sensor will show up in energy dashboard.

Home Assistant: 10$ WiFi Energy plug meters with ESPhome (Grafana) part - 3 - YouTube very helpful video he uses the intergral method.