Energy, Gas and Water consumption overview

vertical-stack-in-card is replaced for the stack-in-card, which also supports horizontal stacks by using mode: horizontal.

Thank you for your code Coen! Mine looks like this right now, still have a lot of work to do but we’re getting there :slight_smile:

1 Like

Hi Coen,

I have a question for you, in your latest update you have a card displaying info about your inverter and panels.

The SolarEdge integration created a sensor called Site Details. Which displays the following info in my setup:

Solar

Can you tell me how you managed to get all the info from that sensor in one card?

Info like panel temperature, number of optimizers etc. isn’t displayed, but I guess my inverter just doesnt share that info :frowning:
Using the API itself I can fetch this data using REST, did you configure some REST-based sensors in HA?

Looking forward to your reply :slight_smile:

Hi Noël, unfortunately I also have the same information as in your screenshot. apparently solaredge no longer sends that information in their API, at least with the solaredge integration. let me know if you have found a solution.

looks good! I have also tried horizontal stacks. It does indeed look better if you make three columns with gas, water and electricity, but run into too many problems on a mobile device. what does your page look like on a mobile device?

Well I now did it kinda the lazy way, just putting the info in a Markdown card. I think a solution is to write REST sensors. You can fetch the info from the API using:

https://monitoringapi.solaredge.com/site/YOUR_SITE_ID/inventory?api_key=YOUR_API_KEY

there should be a way to get a JSON output, haven’t figured out how to do that.

Thank you!, my mobile version looks like this now:

I’m using also the attribute state (last_period) the state is for like second on it’s previous value and afterwards reset to zero.

More people are facing this issue?

image

Guys, this is driving me crazy for today. I tried to setup but can’t get the sensors to work. They dont seem to start/be recognized. I did make some configurations because there are 2 tariffs. Everything to:

  • platform: template
    sensors:

does work perfect. Also the gauges dont work at the moment, that would be a future headache :slight_smile:

# UTILITY METER

utility_meter:
  hourly_energy:
    source: sensor.power_consumption
    cycle: hourly
    tariffs:
      - peak
      - offpeak
  hourly_gas:
    source: sensor.hourly_gas_consumption
    cycle: hourly
  daily_energy:
    source: sensor.power_consumption
    cycle: daily
    tariffs:
      - peak
      - offpeak
  daily_gas:
    source: sensor.hourly_gas_consumption
    cycle: daily
  weekly_energy:
    source: sensor.power_consumption
    cycle: weekly
    tariffs:
      - peak
      - offpeak
  weekly_gas:
    source: sensor.hourly_gas_consumption
    cycle: weekly
  monthly_energy:
    source: sensor.power_consumption
    cycle: monthly
    tariffs:
      - peak
      - offpeak
  monthly_gas:
    source: sensor.hourly_gas_consumption
    cycle: monthly
  yearly_energy:
    source: sensor.power_consumption
    cycle: yearly
    tariffs:
      - peak
      - offpeak
  yearly_gas:
    source: sensor.hourly_gas_consumption
    cycle: yearly
    
input_number:
# STROOM TARIEVEN
    piek_tarief_stroom:
      name: Piektarief Stroom
      initial: 0.23
      min: 0.000
      max: 0.500
      mode: box
      step: 0.001
      unit_of_measurement: 'EUR per kWh'
    dal_tarief_stroom:
      name: Daltarief Stroom
      initial: 0.213
      min: 0.000
      max: 0.500
      mode: box
      step: 0.001
      unit_of_measurement: 'EUR per kWh'      
    vaste_leveringskosten_stroom:
      name: Vaste leveringskosten Stroom
      initial: 71.39 
      min: 0.00
      max: 100.00
      mode: box
      step: 0.01
      unit_of_measurement: 'EUR per jaar'
    netbeheerkosten_stroom:
      name: Netbeheerkosten Stroom
      initial: 252.40
      min: 0.00
      max: 400.00
      mode: box
      step: 0.01
      unit_of_measurement: 'EUR per jaar'
    # GAS TARIEVEN
    all_in_enkeltarief_gas:
      name: All-in enkeltarief Gas
      initial: 0.725 
      min: 0.000
      max: 0.999
      mode: box
      step: 0.001
      unit_of_measurement: 'EUR per m3'
    vaste_leveringskosten_gas:
      name: Vaste leveringskosten Gas
      initial: 71.39
      min: 0.00
      max: 100.00
      mode: box
      step: 0.01
      unit_of_measurement: 'EUR per jaar'
    netbeheerkosten_gas:
      name: Netbeheerkosten Gas
      initial: 191.19
      min: 0.00
      max: 300.00 
      mode: box
      step: 0.01
      unit_of_measurement: 'EUR per jaar'      
      
sensor:
  - platform: dsmr
    port: /dev/ttyUSB0
    dsmr_version: 5

  - platform: template
    sensors:
        hourly_energy:
          friendly_name: Hourly energy
          unit_of_measurement: kWh
          value_template: "{{ states('sensor.hourly_energy_offpeak')|float + states('sensor.hourly_energy_peak')|float }}"
        daily_energy:
          friendly_name: Daily energy
          unit_of_measurement: kWh
          value_template: "{{ states('sensor.daily_energy_offpeak')|float + states('sensor.daily_energy_peak')|float }}"
        weekly_energy:
          friendly_name: Weekly energy
          unit_of_measurement: kWh
          value_template: "{{ states('sensor.weekly_energy_offpeak')|float + states('sensor.weekly_energy_peak')|float }}"
        monthly_energy:
          friendly_name: Monthly energy
          unit_of_measurement: kWh
          value_template: "{{ states('sensor.monthly_energy_offpeak')|float + states('sensor.monthly_energy_peak')|float }}"
        yearly_energy:
          friendly_name: Yearly energy
          unit_of_measurement: kWh
          value_template: "{{ states('sensor.yearly_energy_offpeak')|float + states('sensor.yearly_energy_peak')|float }}"
    # LAST PERIODS GAS
        yesterday_gas:
          friendly_name: Yesterday Gas
          unit_of_measurement: m3
          value_template: "{{ state_attr('sensor.daily_gas','last_period') }}"
        last_week_gas:
          friendly_name: last Week Gas
          unit_of_measurement: m3
          value_template: "{{ state_attr('sensor.weekly_gas','last_period') }}"
        last_month_gas:
          friendly_name: last Month Gas
          unit_of_measurement: m3
          value_template: "{{ state_attr('sensor.monthly_gas','last_period') }}"
        last_year_gas:
          friendly_name: last Year Gas
          unit_of_measurement: m3
          value_template: "{{ state_attr('sensor.yearly_gas','last_period') }}"
    # LAST PERIODS energy
        yesterday_energy:
          friendly_name: Yesterday energy
          unit_of_measurement: kWh
          value_template: "{{ state_attr('sensor.daily_energy_offpeak','last_period')|float + state_attr('sensor.daily_energy_peak','last_period')|float }}"       
        last_week_energy:
          friendly_name: Last Week energy
          unit_of_measurement: kWh
          value_template: "{{ state_attr('sensor.weekly_energy_offpeak','last_period')|float + state_attr('sensor.weekly_energy_peak','last_period')|float }}"        
        last_month_energy:
          friendly_name: Last Month energy
          unit_of_measurement: kWh
          value_template: "{{ state_attr('sensor.monthly_energy_offpeak','last_period')|float + state_attr('sensor.monthly_energy_peak','last_period')|float }}"       
        last_year_energy:
          friendly_name: Last Year energy
          unit_of_measurement: kWh
          value_template: "{{ state_attr('sensor.yearly_energy_offpeak','last_period')|float + state_attr('sensor.yearly_energy_peak','last_period')|float }}"
    # SHORT energy
        daily_energy_short:
          value_template: "{{ '%.3f'%(states('sensor.daily_energy') | float) | float }}"
          unit_of_measurement: 'kWh'

        yesterday_energy_short:
          value_template: "{{ '%.3f'%(states('sensor.yesterday_energy') | float) | float }}"
          unit_of_measurement: 'kWh'

        weekly_energy_short:
          value_template: "{{ '%.3f'%(states('sensor.weekly_energy') | float) | float }}"
          unit_of_measurement: 'kWh'

        last_week_energy_short:
          value_template: "{{ '%.3f'%(states('sensor.last_week_energy') | float) | float }}"
          unit_of_measurement: 'kWh'
        
        monthly_energy_short:
          value_template: "{{ '%.3f'%(states('sensor.monthly_energy') | float) | float }}"
          unit_of_measurement: 'kWh'

        last_month_energy_short:
          value_template: "{{ '%.3f'%(states('sensor.last_month_energy') | float) | float }}"
          unit_of_measurement: 'kWh'

        yearly_energy_short:
          value_template: "{{ '%.3f'%(states('sensor.yearly_energy') | float) | float }}"
          unit_of_measurement: 'kWh'

        last_year_energy_short:
          value_template: "{{ '%.3f'%(states('sensor.last_year_energy') | float) | float }}"
          unit_of_measurement: 'kWh'

    # CACULATIONS
        energy_kwh_to_watt:
          friendly_name: 'Actueel Watt'
          unit_of_measurement: 'Watt'
          value_template: "{{ (states.sensor.power_consumption.state | float * 1000) | round(0) }}"
    #Gemiddeld
        average_gas_day:
          unit_of_measurement: 'm3'
          value_template: >-
            {% set a = states('sensor.last_month_gas') | float %}
            {{ (a / 30.41) | round(3) }}
    #Gemiddeld
        average_energy_day:
          unit_of_measurement: 'kWh'
          value_template: >-
            {% set a = states('sensor.last_month_energy') | float %}
            {{ (a / 30.41) | round(3) }} 
    # INNOVA ENERGIE
    # PRICES GAS
        today_gas_price:
          unit_of_measurement: 'EUR'
          value_template: >-
            {% set a = states('sensor.daily_gas') | float %}
            {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
            {% set c = states('input_number.netbeheerkosten_gas') | float / 365 %}
            {% set d = states('input_number.vaste_leveringskosten_gas') | float / 365 %}
            {{ (((a * b) + c) + d) | round(2) }}

        yesterday_gas_price:
          unit_of_measurement: 'EUR'
          value_template: >-
            {% set a = states('sensor.yesterday_gas') | float %}
            {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
            {% set c = states('input_number.netbeheerkosten_gas') | float / 365 %}
            {% set d = states('input_number.vaste_leveringskosten_gas') | float / 365 %}
            {{ (((a * b) + c) + d) | round(2) }}

        week_gas_price:
          unit_of_measurement: 'EUR'
          value_template: >-
            {% set a = states('sensor.weekly_gas') | float %}
            {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
            {% set c = states('input_number.netbeheerkosten_gas') | float / 52 %}
            {% set d = states('input_number.vaste_leveringskosten_gas') | float / 52 %}
            {{ (((a * b) + c) + d) | round(2) }}

        last_week_gas_price:
          unit_of_measurement: 'EUR'
          value_template: >-
            {% set a = states('sensor.last_week_gas') | float %}
            {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
            {% set c = states('input_number.netbeheerkosten_gas') | float / 52 %}
            {% set d = states('input_number.vaste_leveringskosten_gas') | float / 52 %}
            {{ (((a * b) + c) + d) | round(2) }}

        month_gas_price:
          unit_of_measurement: 'EUR'
          value_template: >-
            {% set a = states('sensor.monthly_gas') | float %}
            {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
            {% set c = states('input_number.netbeheerkosten_gas') | float / 12 %}
            {% set d = states('input_number.vaste_leveringskosten_gas') | float / 12 %}
            {{ (((a * b) + c) + d) | round(2) }}

        last_month_gas_price:
          unit_of_measurement: 'EUR'
          value_template: >-
            {% set a = states('sensor.last_month_gas') | float %}
            {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
            {% set c = states('input_number.netbeheerkosten_gas') | float / 12 %}
            {% set d = states('input_number.vaste_leveringskosten_gas') | float / 12 %}
            {{ (((a * b) + c) + d) | round(2) }}

        year_gas_price:
          unit_of_measurement: 'EUR'
          value_template: >-
            {% set a = states('sensor.yearly_gas') | float %}
            {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
            {% set c = states('input_number.netbeheerkosten_gas') | float %}
            {% set d = states('input_number.vaste_leveringskosten_gas') | float %}
            {{ (((a * b) + c) + d) | round(2) }}

        last_year_gas_price:
          unit_of_measurement: 'EUR'
          value_template: >-
            {% set a = states('sensor.last_year_gas') | float %}
            {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
            {% set c = states('input_number.netbeheerkosten_gas') | float %}
            {% set d = states('input_number.vaste_leveringskosten_gas') | float %}
            {{ (((a * b) + c) + d) | round(2) }}
            
    # PRICES energy
        today_energy_price:
          unit_of_measurement: 'EUR'
          value_template: >-
            {% set a = states('sensor.daily_energy_peak') | float %}
            {% set b = states('sensor.daily_energy_offpeak') | float %}
            {% set c = states('input_number.piek_tarief_stroom') | float %}
            {% set d = states('input_number.dal_tarief_stroom') | float %}
            {% set e = states('input_number.netbeheerkosten_stroom') | float / 365 %}
            {% set f = states('input_number.vaste_leveringskosten_stroom') | float / 365 %}
            {{ ((((a * c) + (b * c) + e) + f)) | round(2) }}
            
        yesterday_energy_price:
          unit_of_measurement: 'EUR'
          value_template: >-
            {% set a = states('sensor.yesterday_energy_peak') | float %}
            {% set b = states('sensor.yesterday_energy_offpeak') | float %}
            {% set c = states('input_number.piek_tarief_stroom') | float %}
            {% set d = states('input_number.dal_tarief_stroom') | float %}
            {% set e = states('input_number.netbeheerkosten_stroom') | float / 365 %}
            {% set f = states('input_number.vaste_leveringskosten_stroom') | float / 365 %}
            {{ ((((a * c) + (b * c) + e) + f)) | round(2) }}  
            
        week_energy_price:
          unit_of_measurement: 'EUR'
          value_template: >-
            {% set a = states('sensor.weekly_energy_peak') | float %}
            {% set b = states('sensor.weekly_energy_offpeak') | float %}
            {% set c = states('input_number.piek_tarief_stroom') | float %}
            {% set d = states('input_number.dal_tarief_stroom') | float %}
            {% set e = states('input_number.netbeheerkosten_stroom') | float / 365 %}
            {% set f = states('input_number.vaste_leveringskosten_stroom') | float / 365 %}
            {{ ((((a * c) + (b * c) + e) + f)) | round(2) }} 
            
        last_week_energy_price:
          unit_of_measurement: 'EUR'
          value_template: >-
            {% set a = states('sensor.last_week_energy_peak') | float %}
            {% set b = states('sensor.last_week_energy_offpeak') | float %}
            {% set c = states('input_number.piek_tarief_stroom') | float %}
            {% set d = states('input_number.dal_tarief_stroom') | float %}
            {% set e = states('input_number.netbeheerkosten_stroom') | float / 365 %}
            {% set f = states('input_number.vaste_leveringskosten_stroom') | float / 365 %}
            {{ ((((a * c) + (b * c) + e) + f)) | round(2) }} 
            
        month_energy_price:
          unit_of_measurement: 'EUR'
          value_template: >-
            {% set a = states('sensor.monthly_energy_peak') | float %}
            {% set b = states('sensor.monthly_energy_offpeak') | float %}
            {% set c = states('input_number.piek_tarief_stroom') | float %}
            {% set d = states('input_number.dal_tarief_stroom') | float %}
            {% set e = states('input_number.netbeheerkosten_stroom') | float / 365 %}
            {% set f = states('input_number.vaste_leveringskosten_stroom') | float / 365 %}
            {{ ((((a * c) + (b * c) + e) + f)) | round(2) }}
            
        last_month_energy_price:
          unit_of_measurement: 'EUR'
          value_template: >-
            {% set a = states('sensor.last_month_energy_peak') | float %}
            {% set b = states('sensor.last_month_energy_offpeak') | float %}
            {% set c = states('input_number.piek_tarief_stroom') | float %}
            {% set d = states('input_number.dal_tarief_stroom') | float %}
            {% set e = states('input_number.netbeheerkosten_stroom') | float / 365 %}
            {% set f = states('input_number.vaste_leveringskosten_stroom') | float / 365 %}
            {{ ((((a * c) + (b * c) + e) + f)) | round(2) }}  
            
        year_energy_price:
          unit_of_measurement: 'EUR'
          value_template: >-
            {% set a = states('sensor.yearly_energy_peak') | float %}
            {% set b = states('sensor.yearly_energy_offpeak') | float %}
            {% set c = states('input_number.piek_tarief_stroom') | float %}
            {% set d = states('input_number.dal_tarief_stroom') | float %}
            {% set e = states('input_number.netbeheerkosten_stroom') | float / 365 %}
            {% set f = states('input_number.vaste_leveringskosten_stroom') | float / 365 %}
            {{ ((((a * c) + (b * c) + e) + f)) | round(2) }}

        last_year_energy_price:
          unit_of_measurement: 'EUR'
          value_template: >-
            {% set a = states('sensor.last_year_energy_peak') | float %}
            {% set b = states('sensor.last_year_energy_offpeak') | float %}
            {% set c = states('input_number.piek_tarief_stroom') | float %}
            {% set d = states('input_number.dal_tarief_stroom') | float %}
            {% set e = states('input_number.netbeheerkosten_stroom') | float / 365 %}
            {% set f = states('input_number.vaste_leveringskosten_stroom') | float / 365 %}
            {{ ((((a * c) + (b * c) + e) + f)) | round(2) }}

Can you maybe help :smile:

EDIT: Managed to fix this. My YAML code wasn’t right

How did you get DSMR reader and this utility working together?

I’m already using DSMR reader but am at a loss on how to get this working also.

I use the mqtt function in DSMR-reader to send it to Home Assistant

I’m also using the MQTT and have it configured in home assistant and it’s working but it does not have enough details, example month gas usage and month power usage. This utility does that. However I’m using home assistant on my Synology nas and the DSMR with P1 on my raspberry pi.

It’s this part in your config that I don’t know what to do with, since the P1 reader is not attached to the device running home assistant.

- platform: dsmr
  port: /dev/serial/by-id/usb FTDI_FT232R_USB_UART_AK3EMMXY-if00-port0
  dsmr_version: 5

Hi, I’m not using - platform: dsmr but DSMR-Reader. Connect the p1 -> USB to the device where DSMR-reader is running on (i am using Docker) from DSMR-Reader it sends his data over MQTT to home assistant.
put this in the sensor.yaml - platform: dsmr_reader

See my earlier post

https://community.home-assistant.io/t/energy-gas-and-water-consumption-overview/151306/10?u=coen17st

Manny thanks for sharing this :slight_smile:

suggestion for your code :wink: i made a little change for the week en month calc like this :slight_smile:
Now at the day of week or day of month calculated the price for:

  • input_number.vermindering_energiebelasting_stroom,
  • input_number.vaste_leveringskosten_stroom,
  • input_number.netbeheerkosten_stroom

So on monday just add 1 day of cost so you will not start negative cost at the calculation. I also try this for the gas

  month_power_price:
    unit_of_measurement: 'EUR'
    value_template: >-
      {% set a  = states('sensor.monthly_energy_offpeak') | float %}
      {% set aa = states('input_number.dalltarief_stroom') | float %}
      {% set b  = states('sensor.monthly_energy_peak') | float %}
      {% set bb = states('input_number.normaaltarief_stroom') | float %}
      {% set c  = states('input_number.netbeheerkosten_stroom') | float / 365  * (now().day-1) %}
      {% set d  = states('input_number.vaste_leveringskosten_stroom') | float / 365  * (now().day-1) %}
      {% set e  = states('input_number.vermindering_energiebelasting_stroom') | float / 365  * (now().day-1) %}
      {{ ((((a * aa) + (b * bb) + c) + d) + e) | round(2) }}

1 Like

Hi,

I’m quite new to HA and trying to implement this.
On the 1th of march I started a new contract with Oxxio.

I have peak and off-peak tariff but not sure how to implement this. I have to setup from the opening post up and running as test but how to advance.
I have to change the initial off course, but how to get these values? Is this just the start measurement from Oxxio?

Can someone help me out with the peak and off peak tariff?

Can I just copy/paste all (groups, utilitymeter and sensor) of the above to my configuration.yaml and that’s it?

1 Like

Just a quick update; started using dsmr-reader so solved :slight_smile:

Hi Dirk

Like your metering page.
Could you be so kind to share us your Lovelace code?

Did you use anything special for it? Themes etc

everything works as it should except the ui-lovelace:
I keep getting this error no card type configured ?

Does anyone have this with also SolarEdge/Solor use and prices for back to grid?

When I start using the energy info I entered a wrong tarif. I changed it afterwards, but now the totals are incorrect. Is there a way to clear the data, but only the energy data?

I cant get the gas price set higher than 1 euro… 0.999 is the max… why is that?

gasprijs

and wow… one time my m3 was 0.72 euro… now its around 1.72… where did it go wrong and where does this go?