Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Minimum Consecutive Hours for Split #160

Open
sembeek opened this issue Oct 8, 2024 · 12 comments
Open

Feature Request: Minimum Consecutive Hours for Split #160

sembeek opened this issue Oct 8, 2024 · 12 comments

Comments

@sembeek
Copy link

sembeek commented Oct 8, 2024

Hi,

First of all, thank you for this fantastic project! It's been incredibly helpful for a variety of tasks in my setup.

One feature I'd love to see (or perhaps it already exists, and I haven't figured it out) is related to calculating the 8 cheapest hours for my heat pump. Specifically, I'd like to be able to "split" these hours, so that the system can schedule, for example, 4 cheaper hours at night and 4 in the afternoon.

However, with the current implementation, I’ve noticed that the system sometimes selects short periods, such as a single hour, before stopping, which isn’t ideal for a heat pump since it requires longer operational periods.

Would it be possible to add an option that enforces a minimum number of consecutive hours when splitting? This would ensure the heat pump runs efficiently without frequent starts and stops.

Looking forward to your thoughts!

Best regards,
Sem

@rrooggiieerr
Copy link
Contributor

I'm quite sure you can use the hours parameter to set the number consecutive hours to be used, thus:

hours=4

@sembeek
Copy link
Author

sembeek commented Oct 8, 2024

That will just specifiy for how many hours it will search right?
In my experience it is possible that hours=4 can choose 2 hours in the night and 2 in the afternoon, in combination with split.

What should be nice if there is like an option:
hours=8, consecutive=4, split=true

@rrooggiieerr
Copy link
Contributor

If you look at this example from the documentation I would think it's about the duration

{% from 'cheapest_energy_hours.jinja' import cheapest_energy_hours %}
{% set output = cheapest_energy_hours(sensor='sensor.cheap_energy', hours=2.25, start='12:00', end=today_at('19:00') + timedelta(days=1), look_ahead=true) %}

But that's very easy to test in Developer Tools > Template

@rrooggiieerr
Copy link
Contributor

Actually, I'm using the hours parameter in one of my automations and it works exactly like your usecase

@sembeek
Copy link
Author

sembeek commented Oct 8, 2024

I understand what you are saying, but you are not using the split parameter.
I would like to use the split parameter so the hours can be split in day and night if that is cheaper.
So the following template:

{% from 'cheapest_energy_hours.jinja' import cheapest_energy_hours %}
{{ cheapest_energy_hours('sensor.epex_spot_data_net_price', time_key='start_time', value_key='price_ct_per_kwh', price_factor=0.01, include_today=true, include_tomorrow=false, hours=8, lowest=true, split=true, mode='all') | from_json  }}

Will return:

[
  {
    "start": "2024-10-08T00:00:00+02:00",
    "end": "2024-10-08T06:00:00+02:00",
    "hours": 6,
    "prices": [
      0.23694,
      0.22881,
      0.22425,
      0.21774,
      0.2174,
      0.22809
    ],
    "is_now": false
  },
  {
    "start": "2024-10-08T12:00:00+02:00",
    "end": "2024-10-08T13:00:00+02:00",
    "hours": 1,
    "prices": [
      0.23427
    ],
    "is_now": true
  },
  {
    "start": "2024-10-08T23:00:00+02:00",
    "end": "2024-10-09T00:00:00+02:00",
    "hours": 1,
    "prices": [
      0.23066
    ],
    "is_now": false
  },
  {
    "total_hours": 8,
    "datapoints_per_hour": 1,
    "datapoints": 8
  }
]

But i would like it to returns the 2 most cheap 4 consecutive hours. So it is okay if it runs 8 hours in the afternoon if that are the 8 most consecutive hours, but it should return 4 hours at night and 4 hours at the afternoon if they are the cheapest consecutive hours.

@rrooggiieerr
Copy link
Contributor

Ok, I might have misunderstood your initial request as I thought it to be more focused on the consecutive hours. My thoughts were you could create your own automation that calculates the cheapest 4 hours in the morning and cheapest 4 hours in the afternoon.

@rrooggiieerr
Copy link
Contributor

My suggestion would be to have your feature request to be to allow integer values for the split parameter where true and false (default) would work as currently implemented and an integer value would return a maximum number of splits. split=2 would then give you the 2 periods within the day that are cheapest

@KrzysztofHajdamowicz
Copy link

I'm not sure if it's something worth pursuit.

Just look for 4 hours between 02:00 and 12:00 and 4 hours between 14:00 and midnight or something like this.

You can compare current hour to decide which start and end values are given to macro so you can still use single binary sensor entity.

@sembeek
Copy link
Author

sembeek commented Oct 8, 2024

Yeah but that would not work if the 8 cheapest hours are between 10:00 and 18:00 for example.

@KrzysztofHajdamowicz
Copy link

But is single 8h run enough for heating home during 24h window?

I bet single 4h run provides heat for next 12h and running pump longer won't help as heat reservoir is already full.

Also, as heat pump prefer longer runs where it can just keep heat reservoir topped-off, I'd suggest to search 2-4 most expensive hours and disable heat pump during that time.
It will give long cycle times and better thermal comfort.

@sembeek
Copy link
Author

sembeek commented Oct 8, 2024

Single 8h run is enough for my home, i have a really well isolated small appartment, so it does not need much.
I still have a home assistant thermostat attached to it, so it won't turn on if it already met the temperature.
With a lot of tinkering and monitoring i found out that around 8 hours a day is the most efficient for me, it does not matter if it is splitted in 2 times 4 hours or 8 hours straight.

@TheFes
Copy link
Owner

TheFes commented Oct 8, 2024

I understand the request, you basically want a minimum period length in case split=true is used
I'm kinda busy at the moment, but I will try to find some time to implement this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants