Energy: Add fixed daily cost

Yes Please

I would like this too. Seems like a simple feature to add.

Also the case in New Zealand.

This would be great in the UK - and the integration from GitHub - HandyHat/ha-hildebrandglow-dcc: Home Assistant integration for UK SMETS (Smart) meters pulling data from the DCC via the Hildebrand Glow API provides a daily standing charge rate sensor which it gets direct from the supplier.

Agreed, even have a customizable ‘static’ additional daily/monthy or configurable period to add to the energy cost dashboard.

So define if it’s daily, weekly or monthly and then the value to add per that period. Then when to apply, at the end of the period (24h for a day, at the start or end of the day or even a calculated field to apply it per period)

Adding a daily charge is something that can be done in your tariff / utility meter setup.
Here’s what I’m using to calculate the cost of import / exported, then calculate the correct tier (peak / shoulder / off-peak) that should be used for that time of day and then add in the daily connection fee and work out the current daily cost for power for that day.

See: Home-Assistant/energy_tariff_TOU_solar_analytics.yaml at 4fd711b2ac24cf1893a039919bbe6889a06b2681 · Roving-Ronin/Home-Assistant · GitHub

I’m using Solar Analytics as the data source for kW etc, but just update it to whatever your using (which btw should be the cumulative import / export costs, not the daily/todays like I have…side issue being flagged atm for SA integration to fix).

This is based upon original code by SgtBatten, and I still have to get a chance to also work up a version that supports peak / shoulder / off-peak + demand based fee (charged based on the highest 30min kWh consumption during peak hours for the month x a per kWh demand fee).

1 Like

i can agree that for charge per kWh you shoud use automations / integrations. Too many variants across countries.

but i think if even a additional daily fixed cost what could be added to Power, Water and Gas would fix the need for most cases.

so my vote would be also to have the same settings additional that is time based. Reading description of users above this would fit the most cases. (if you have to pay montlhy or hourly)
and for the price give us the same options as the ones that we have for the working prices

1 Like

I used the same kind of trick as @muzzak, by creating two sensors counting upwards 0.01 kwh and 0.01 m3 each day. This way you can give your fixed daily energy company charge in cents per day.

I run into the same issues as @trumee , but this was because I didn’t had the time_date integration activated.

To help others, this is my config in the configuration.yaml

sensor:
  - platform: time_date
    display_options:
      - 'date_time_iso'

template:
  - sensor:
    - name: "Daily Energy Supply Charge"
      unit_of_measurement: "kWh"
      device_class: energy
      state_class: total_increasing
      state: "{{ (((as_timestamp(states('sensor.date_time_iso')) / 3600) - 454585) | int) / 2400 }}"
      attributes:
        last_reset: '1970-01-01T00:00:00+00:00'

  - sensor:
    - name: "Daily Gas Supply Charge"
      unit_of_measurement: "m³"
      device_class: gas
      state_class: total_increasing
      state: "{{ (((as_timestamp(states('sensor.date_time_iso')) / 3600) - 454585) | int) / 2400 }}"
      attributes:
        last_reset: '1970-01-01T00:00:00+00:00'

For the Dutch ANWB Energie (in 2023) the daily charge in euro-cents are:
electricity:-45,61 (negative because of Dutch energy tax return)
gas: 69,58

results into:

Hope this helps others

8 Likes

As a HA beginner, this helped me a lot, thank you very much!
i just recently moved to nl…
This are my daily/yearly costs:
Gas:
€ 0,46090 per dag + € 67,36 per jaar
Electricity:
€ 0,73790 per dag + € 67,36 per jaar
This is without btw…
I think i have a bad contract :confused:

It’s been a while since my original post and it seems a few people are having trouble implementing my/others solution particularly for differing periods, so I thought I’d revisit it hopefully making things a bit easier. My config is below.

# Minimal configuration of the standard time and date sensor
sensor:
  - platform: time_date
    display_options:
      - 'date_time_iso'

template:
  - sensor: 
    - name: "Supply Charge"
      unit_of_measurement: "Wh"
      device_class: energy
      state_class: total_increasing
      state: >-
        {{ int(as_timestamp(now()) | timestamp_custom("%d")) + 1 - int(as_timestamp("yyyy-mm-dd") | timestamp_custom("%d")) }}

To make this work you need to know your supply charge cost and period.
In the example above the %d is for daily. If you have a differing period you can use any one of the
python date format codes here Python Dates
eg if your charge period is

  • hourly use %H (Hour (00-23))
  • daily use %d or %j
  • weekly use %V (ISO 8601 weeknumber)
  • monthly use %m (Month as a number 01-12)
  • yearly use %y or %Y
    etc…

Make the change to the code for your charge period (note it must be changed in 2 places)
Change the yyyy-mm-dd to todays date eg 2023-07-05 for 5th July 2023.
Insert the above code into your configuration.yaml
Goto Developer Tools - YAML and click All YAML Configuration to reload the config
Goto Settings - Dashboards - Energy - Add Consumption
Select Supply Charge sensor from the drop down list
Select Use a static price and enter your supply charge for the period multiplied by 1000

That’s it. The supply charge should show up in the Energy dashboard and change every supply period.
Note the data may take a while to show up in the dashboard

Hope this helps people

4 Likes

I don’t understand why you use this?
First: We have to use a default value.

as_timestamp("yyyy-mm-dd", default=0)

And the result is always the default value in my installation.

@Herr.Vorragend You need to replace the text yyyy-mm-dd with todays date so you will have something like as_timestamp(“2023-07-09”)
Also the default option is only needed if the first value fails the conversion to UNIX timestamp. In my example this shouldn’t occur, so for simplicity I didnt include it. You can if you want to. If you had “yyyy-mm-dd” in the first value it will always fail and give you the default, since you can’t convert the text yyyy-mm-dd into a timestamp.

Oh, how stupid. I didn’t read this. Thank you.

I seem to have done things somewhat differently from others – a meter permanently showing 0 and a total cost sensor that increments daily:


- trigger:
  - platform: time
    at: "00:00:05"
  sensor:
  - name: "Smart Meter Electricity: Standing Charge"
    unique_id: smart_meter_electricity_standing_charge
    device_class: monetary
    unit_of_measurement: "GBP"
    state_class: "total"
    icon: mdi:cash
    state: >
      {% if as_datetime(this.last_changed) > today_at('00:00')
      and has_value('sensor.smart_meter_electricity_standing_charge') %}
      {{ states('sensor.smart_meter_electricity_standing_charge') }}
      {% else %}
      {{ states('sensor.smart_meter_electricity_standing_charge') | float(0) +
         states('sensor.smart_meter_electricity_import_standing_charge') | float }}
      {% endif %}
  - name: "Smart Meter Electricity: Standing Charge Usage"
    unique_id: 6280CFF8-3B92-46D1-9BDF-4C386E85D818
    device_class: energy
    state_class: total_increasing
    unit_of_measurement: kWh
    state: "0"

Those sensors are then set up for use like this:

Alt text: The “Configure grid consumption” dialog from the energy dashboard configuration view. The “Smart Meter Electricity: Standing Charge Usage” sensor is used for the “Consumed Energy” field, and cost tracking is done by “Use an entity tracking the total cost” with the “Smart Meter Electricity: Standing Charge” sensor being the entity tracking the total costs.

I have the current standing charge supplied in sensor.smart_meter_electricity_import_standing_charge over MQTT, you’ll need to make sure it’s available. It works by adding the current daily standing charge to the existing value of the sensor if its last update wasn’t after today at midnight – the template is set to only trigger once daily, but it’ll still work if it’s triggered more often.

I have the same setup for gas, which works nicely as during the summer it’s plausible that the house won’t actually use any gas some days. So I avoid registering even a nominal amount of fake usage.

3 Likes

nope cant get this to work :confused: dont have a clue what i am doing

Quick question here. From NZ and we have the same sort of charge here. I have an entity which is Powershop Daily Charge, which is currently = $1.03 and gets updated on a daily basis (it has not changed for a while tho). Would there be a way to use this as the price rather than using a static number?

Hmmm - tricky. If there is a web page or app with the daily charges on it, you maybe able to download it to a separate entity and then use it with the “Use an entity with current price” option in your energy dashboard. Also this guy @joem seems to have managed to do a bit with Powershop data. Scrape sensor improved - scraping multiple values - #280 by stepsolar
Maybe ask him if he’s solved it ?

Yea so thats the exact code im using to bring the data into the entity. Using your original suggestion and having a bit of a play with it after i posted yesterday, i have it working! This morning it added $1.03 as a fixed charge for the day. Super happy with the result, thanks for sharing your solution. I actually ended up using the same thing for my gas bottle monitoring as well.

What i had todo is create an entity as follows, and then select that as the entity with current price (sensor.powershop_daily_charge being the scraped charge in $) in the energy dashboard:


- platform: template
    sensors:
      powershop_supply_charge_nzd_wh:
        friendly_name: "Powershop Supply Charge NZD Wh"
        unit_of_measurement: "NZD/kWh"
        device_class: monetary  
        value_template: "{{ (states('sensor.powershop_daily_charge') | float * 1000) | round(3) }}"

1 Like

@muzzak - One of the things I have observed is that the daily charge is added at 10pm each evening. Would this be because I setup the entity in your code around then? I was looking for a way to change it so that it is added at the beginning of the day so it shows as part of that days charges.

@Greminn - If you’ve set it up as I did (below for ref) then the sensor will be “total_increasing” every day. That’s using timestamp_custom(“%d”). At midnight it will increase by 1. You can easily check this by looking at the values for sensor “Supply Charge” through HA - Settings, Devices and Services, Entities and search for Supply Charge. It should increase by 1 at midnight every day.