Get value starting from a specific date

Hi,

For my energy card I want to get the total energy imported from the grid starting at a specific date. My contract is from the 19th of February till the 19th of February. I know I can get the total from this year but I need to get the total starting from the 19th of February till now and counting.

Does anyone know how to get this done?

This is the sensor I used for my helper to get the total of this year
sensor.p1_meter_3c39e72f22ca_total_power_import

Regards,
Robert

Utility meter helper with a yearly cycle and a 50 day offset ( Jan = 31 + 19 Feb). You can use the calibrate service to set the current value.

Thanks for your reply, I have no idea how to work with this type of things but am I close?

utility_meter:
  energy:
    source: sensor.import_energie_vanaf_19_feb
    cycle: yearly
    offset:
      days: 48
      hours: 0
      minutes: 0

This is in the configuration.yaml

The 19th of Feb is day 50, and you don’t need to specify the hours or minutes.

utility_meter:
  energy:
    source: sensor.import_energie_vanaf_19_feb
    cycle: yearly
    offset:
      days: 50

Thanks but when I enter this code and check the configuration file I got this:

Invalid config for [utility_meter]: Unsupported offset of more than 28 days, please use a cron pattern. for dictionary value @ data[‘utility_meter’][‘energy’][‘offset’]. Got OrderedDict([(‘days’, 50)]). (See /config/configuration.yaml, line 35).

Ah, bugger. I was not aware of that limitation.

To use cron instead you could do this:

utility_meter:
  energy:
    name: "Yearly Energy"
    source: sensor.import_energie_vanaf_19_feb
    cron: "0 0 19 2 *"

See: Crontab.guru - The cron schedule expression editor