Utility meter bevahing a bit strange

Might be that I don’t understand it fully but I would like to display daily power consumption using the utility meter. I would like it to look like the Energy dashboard with one bar per day but with more flexibility using Apex Charts. Here is the sensor:

And the code:

utility_meter:
  energy_daily_kwh:
    source: sensor.sensor.last_meter_consumption_vagen
    cycle: daily
    name: Elförbrukning - dag kwh

The outcome from the utility meter is a graph that doesn’t have one bar per day as I would like:

As I udnerstood it, the utility meter would gather data from one day (the total amount consumed) and store it as one value for that day. Here there are tons of values for each day. What am I missing?

Use that sensor in a custom:mini-graph-card in lovelace and you can set it up to do what you would like.

Tack Tomas :slight_smile:

Problem is that it doesn’t help so I’m thinking that I might put the wrong data into the utility meter. When you create the utility meter, what sensor do you use? Do you use a sensor that accumulates the power consumption every day like the first screenshot in my first post? Or do you use the sensor that shows the actual power consumption and updates constantly?
I have a Tibber P1 that monitors the power consumption and an Easee car charger.

Edit, got the mini graph card to work but not Apex Chart and that’s the one I would prefer…

You need to group by day. Here’s my daily rainfall apexchart as an example:

Screenshot 2022-02-18 at 00-48-03 Overview – Home Assistant

type: custom:apexcharts-card
apex_config:
  chart:
    height: 140%
  dataLabels:
    background:
      enabled: false
    style:
      colors:
        - var(--primary-text-color)
graph_span: 1w
span:
  end: day
header:
  show: true
  title: Daily Rainfall
series:
  - entity: sensor.weatherflow_precipitation_today
    type: column
    show:
      datalabels: true
    group_by:
      func: last
      duration: 1d
    unit: mm
1 Like
utility_meter:
  daglig_billaddning:
    source: sensor.total_consumption_kwh
    cycle: daily 

and that sensor is made from

sensor:
  - platform: template
    sensors:
      total_consumption_kwh:
        friendly_name: "Typ 2 Kwh"
        value_template: "{{ state_attr('sensor.tomas_hedlund_halo_1', 'total_consumption_kwh') }}"
        unique_id: total_consumption_kwh
        icon_template: mdi:flash
1 Like

Thank you, I got it to work thanks to your code. I was missing the “span: end: day” and “group_by duration: 1d”.

1 Like

how can your graph be blue?
mine is red and don´t seem to find out where to change the color?

I’m actually using an experimental feature that colours the graph according to the state of the sensor. I left that bit out so as not to confuse you. Here’s the full card config:

type: custom:apexcharts-card
apex_config:
  chart:
    height: 140%
  dataLabels:
    background:
      enabled: false
    style:
      colors:
        - var(--primary-text-color)
graph_span: 1w
span:
  end: day
header:
  show: true
  title: Daily Rainfall
experimental:
  color_threshold: true
series:
  - entity: sensor.weatherflow_precipitation_today
    type: column
    show:
      datalabels: true
    group_by:
      func: last
      duration: 1d
    unit: mm
    color_threshold:
      - color: '#039BE5'
        value: 0
      - color: '#0da035'
        value: 2.5
      - color: '#e0b400'
        value: 5
      - color: '#e45e65'
        value: 10
card_mod:
  class: top-level-chart

But if you only want to change the colour of your graph you can do it with the series option:

series:
  - entity: sensor.weatherflow_precipitation_today
    type: column
    color: blue

You should learn how to read the documentation for the card:

I did that under the series but it wouldn’t change the color, i actually did read it but figured i missunderstod something.
I’ll have to keep trying, thx

Share your card config that isn’t working.

Got it to work now, did the same as before but now it just worked, must have been some Reload of page or something but now Its blue and nice, much better than the mini graph card. Thx :+1:

1 Like

Taking a chance and hoping that anyone of you are using the utility meter to calculate the monthly electricity cost?

Is this an OK way of doing it? sensor.elforbrukning_manad is a sensor accumulating kWh for the current month and is set to 0 end of month. Can I use this and the amount calculaton in the utility meter?

Calculating the cost for the current month:

- platform: template
    sensors:
      energy_cost_this_month:
        friendly_name: "Elkostnad aktuell månad"
        unit_of_measurement: 'kr'
        icon_template: mdi:home-lightning-bolt-outline
        value_template: "{{ (((states('sensor.elforbrukning_manad') | float * 1.37) ) + 556.25) | round(0) }}"

Storing that cost in the utility meter:

utility_meter:
  energy_cost_monthly:
    source: sensor.energy_cost_this_month
    cycle: monthly
    name: Elkostnad - månad

If you already have a monthly energy sensor, sensor.elforbrukning_manad, why do you need a monthly utility meter?

The sensor.elforbrukning_manad is a utility meter with cycle monthly. It stores the monthly kWh consumption.

The tempalte sensor then calculates the electricity cost and stores it in another utility meter.

As I understand it, the utility meter is the way to go if I want to store monthly values over a long period of time (year).

You don’t need to do that, the template sensor will reset when the energy utility meter does, so no need for another utility meter to track the cost.

Thanks for your replies.

But if I want to make a graph for 12 months with the electricity cost then I need to store one value per month. Don’t I need a utility meter for that?

Nope. It will have the same problem as the sensor.

If you want to make a 12 month graph you need to store the data for 12 months. I would suggest Influxdb for this.

Alright, too bad, thanks for your help.