Is there a way to set Utility meter' offset day?

Is there a way to change the utility meters offset day programatically without going in code… Created a utility meter using the devices helper menu but once created I dont see the setting to change the offset day… so I created the meter in configuration.yaml… but I want an easy way to change the values in the future… I thought of using a input_number helper as a variable to change the offset. but it does not work…

utility_meter:

  energyimport:

    source: sensor.import_energy

    cycle: monthly

    offset:

      days: {{states('input_number.reading_day')}}

thanks…

1 Like

No there is no way to do this.

It might help if you describe the problem you are trying to solve, not your chosen solution. (X-Y problem)

The problem is creating a utility type meter to show the readout of energy kwh and cost per month with configurable electricity rates and offset day… because the reading day and electricity rates can change… so i wanted something easier to change the values when they do change…

The way I do this is to put the rates in an input number and calculate the cost in a template sensor.

You can now just supply the input number to the energy dashboard if that is what you are using.

thanks… but values there in the energy dashboard I think does not reflect on my electricity bill… there is a previous and current kWh reading and it is read at a some day of every month. so to be able to predict what Im gonna pay next month… Im trying to do something like this. I manage to do the rates… the offset day is where I stumble…

1 Like

just so someone had the same problem… I gave up using a utility meter. instead…I manage to solve it… by instaling variables integration via hacs… the variable is used to store previous reading… by time trigered automation reading the offset day value from the input_number… reseting the meter and saving the previous kwh reading in a variable… which is then used to calculate the monthly consuption and the cost…

1 Like

You could also look at creating a history stats sensor. Just putting an alternative out there.

I am also looking for a way to have utility meter follow the schedule of my utility.

I have a set of daily/weekly/monthly/yearly utility meters configured using standard ‘calendar’ reset days. And then additional utility_meters for which I want to follow my utility. I’m doing this so I can weigh the benefits of going to a different rate plan and if it makes sense for my usage patterns.

I have resorted to manually changing the offset monthly but that is less than ideal in my ‘automation’ system :slight_smile: . I have a sensor which has stored the next ‘meter read’ date (which can fluctuate from the ~8th of the month to the ~12th). I have then made an input_number which stores the date of reset (day). I would like the utility meter to reset on those dates so my tariffs, which change based on usage from the last meter read, are correctly configured.

I’m interested in the specifics of how @kmb36td was able to accomplish this in storing the value in a variable. That may just be the workaround I’m looking for.

I’ll also look into he history stats sensor @parautenbach mentioned.

To change when a utility meter resets.
Set it to not reset automatically.
From an automation, call the servise !Utility Meter: Reset!.

hi, could you share how you use history_stats in this situation?

Take a look at this example in the docs:

sensor:
  - platform: history_stats
    name: Lamp ON today
    entity_id: light.my_lamp
    state: "on"
    type: time
    start: "{{ today_at() }}"
    end: "{{ now() }}"

So, if I understood you correctly, you wanted to use a dynamic value for the day of reading:

days: {{states('input_number.reading_day')}}

With history stats you can thus do this to read from the next day of the previous month until the current reading day:

    start: >-
      {% set end = states('input_number.reading_day') | as_datetime %}
      {{ (end.replace(month=end.month - 1) if end.month > 1 else end.replace(month=12, year=now().year - 1)).replace(hour=0, minute=0, second=0, microsecond=0) }}
    end: "{{ states('input_number.reading_day') }}"

thanks but how do i use history_stats to track the daily last state value (it is an increasing kWh number) of a total_increasing device?
what value should i use in the ‘state’ of the history_stats?

ok i found the answer to op’s problem

to solve it, switch off periodical reset of the utility_meter by not including ‘cycle’ or cron in the configuration.yaml. Then use automation to utility_meter.reset at specific time/day.

1 Like