How can I best pass data from emails to Home Assistant, with a delay?

Every mid-month I receive a standard email with the energy tariffs for the following month.
How can I best pass those data to Home Assistant?

My first idea would be to use a script which processes emails (I use “imapfilter” already) and via a local URL updates input_number.next_tariff, together with an automation running the first of the month copying input_number.next_tariff to input_number.current_tariff, which would then be used as entity to track current prices for the energy dashboard.

Unfortunately, the tariffs are not available on the website unless login is performed and so on, so a web scraper is too complex for my skills.

Are there other options? this seems quite rough.

Also, how do I update an input_filter via a URL?

Hey!
Your proposed approach sounds good to me. Parsing from the webpage would be nicer, agreed, but if that is not possible imho your mail parsing approach sounds quite okay.

  1. parse email
  2. store in next_tariff
  3. load into current_tariff start-of-month

How can I best pass those data to Home Assistant?

Check here: REST API | Home Assistant Developer Docs under POST states. e.g.:

curl -X POST -H "Authorization: Bearer ABCDEFGH" \
  -H "Content-Type: application/json" \
  -d '{"state": "25", "attributes": {"unit_of_measurement": "°C"}}' \
  http://localhost:8123/api/states/sensor.kitchen_temperature

Ok that’s why I couldn’t find it in the normal documentation, thanks.

I also didn’t think about passing the unit of measure, indeed it’s the correct way to proceed.

Good luck!
You can pass any attributes as you see fit. You could also add useful self-defined attributes, .e.g. mail_datetime or valid_starting_datetime - in case there is further data in the email you deem useful or that could be helpful to debug an issue later on.

Cheers