Montly changing energy costs

with my current energy provider, they change on a monthly basis the costs of Electricity and Gas. Can we add a variable that changes by month to adjust the cost for the new or even the past month.

Yes you can.

That’s what this option does:

Use an input number, or a sensor if you can get the cost automatically.

how do we setup the entity with current price, I mean how to define it?

You can use an input number helper that you update manually, or if you have some way of obtaining the price automatically you could use a template sensor or restful sensor.

our prices definded as


and

LESCO Electricity Unit Price

Lesco electricity unit price for domestic users are as follow:

> 1st 100 units price = Rs – 12.90 / unit
> After 100 units price = Rs – 13.54 / unit

So I have to create total of 10 sensors?

My current setup

#percentage of enrgy produced 
template:
  - sensor:
      - name: "Percentage of energy produced"
        unit_of_measurement: "%"
        state: >
          {% set daily_yield = states('sensor.daily_yield') | float(0) %}
          {% set Estimated_production_today = states('sensor.energy_production_today') | float(1) %}

          {{ ((daily_yield /Estimated_production_today ) * 100) | round(1, default=0) }}  
        availability: >
          {{ states('sensor.daily_yield') not in [ unknown, unavailable, none ] and
             states('sensor.energy_production_today') not in [ unknown, unavailable, none ] }}
sensor:
  - platform: template
    sensors:
      # sensor used to show power flow from Panels to Grid, but shows a negative at night
      template_grid_feed_in:
        friendly_name: "Solar 2 Grid"
        unit_of_measurement: "W"
        device_class: power
        value_template: >
          {% if states('sensor.grid_active_power') | int > 0 %}
            {{ states('sensor.grid_active_power') }}
          {% else -%}
            0
          {% endif %}

      # sensor used to show power flow from Panels to Grid and doesn't allow it to show a negative number only positive numbers
      template_grid_consumption:
        friendly_name: "Grid 2 House"
        unit_of_measurement: "W"
        device_class: power
        value_template: >
          {% if states('sensor.grid_active_power') | int > 0 %}
            0
          {% else -%}
            {{ (states('sensor.grid_active_power') | int) | abs }} 
          {% endif %}

      # shows the solar power being fed to the house and doesn't allow it to show a negative number only positive numbers
      template_curent_solar_consumption:
        friendly_name: "Solar 2 House"
        unit_of_measurement: "W"
        device_class: power
        value_template: >-
          {% if states('sensor.template_grid_consumption') | float > 0 %}
            {{ states('sensor.active_power') }}
          {% else -%}
            {{ (states('sensor.active_power')| float - states('sensor.template_grid_feed_in')| float) }}
          {% endif %}

utility meter

utility_meter:
  grid_import_solar_daily_energy:
    source: sensor.grid_consumption
    cycle: daily
  grid_export_solar_daily_energy:
    source: sensor.grid_exported
    cycle: daily

No just one that changes based on date, time and energy used so far.

1 Like

Will this work

  daily_energy:
    source: sensor.grid_consumption
    unique_id: 'Lesco_daily'
    name: Daily Energy
    cycle: daily
    tariffs:
      - peak
      - offpeak
  monthly_energy:
    source: sensor.grid_consumption
    unique_id: 'Lesco_monthly'
    name: Monthly Energy
    cycle: monthly
    tariffs:
      - peak
      - offpeak  

spelling error.

does the variable recalculates the total energy cost, or just the moment in time when i adjust the input number?

2 Likes

@tom_l I modified the code

 lesco_daily_energy:
    source: sensor.grid_consumption
    unique_id: 'Lesco_daily'
    name: Lesco Daily Energy
    cycle: daily
    tariffs:
      - peak
      - offpeak
  lesco_monthly_energy:
    source: sensor.grid_consumption
    unique_id: 'Lesco_monthly'
    name: Lesco Monthly Energy
    cycle: monthly
    tariffs:
      - peak
      - offpeak  

but it created these entities

Edit:
added following automation for current peak and off hours

alias: 'Peak and off peak tariff '
description: ''
trigger:
  - platform: time
    at: '18:00:00'
  - platform: time
    at: '22:00:00'
condition: []
action:
  - service: utility_meter.next_tariff
    data: {}
    target:
      entity_id: utility_meter.daily_energy
  - service: utility_meter.next_tariff
    data: {}
    target:
      entity_id: utility_meter.monthly_energy
mode: single

Moving this to configuration as it is no longer a feature request.

Only if this was easily available in helpers utility UI. It could make our lives a lot easier.

It would be very difficult to account for the myriad of charging schemes power companies have come up with. This way is far more flexible and caters to everyone.

why are these sensors paused? It is off-peak time in my time zone.

Because the sensor you feed the utility meter with is not updating?


it was update 7mins ago.
Found the reason, there is no consumption from the grid right now. :man_facepalming:
image

how to set the price after the first day of month already started? what about the calculation of the monts earlier?

2 Likes

bump: can somebody help me with the changing cost? and the reverse calculation?

You can not retroactively alter the cost calculations already made, unless you are really good with SQL then maybe you could alter the database directly. Don’t ask me how to do that. I don’t know.