BottlecapDave / HomeAssistant-OctopusEnergy

Unofficial Home Assistant integration for interacting with Octopus Energy
https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy/
MIT License
572 stars 57 forks source link

Support decimal weighting for target rates #1008

Open henrik-brodtkorb opened 1 day ago

henrik-brodtkorb commented 1 day ago

Describe the feature

First of off, thanks for building and maintaining the Octopus Energy HA integration.

This feature request is to allow decimal numbers for the weighting. This will allow for more accurate weighting.

Expected behaviour

Given the example in the docs:

There may be times when the device you're wanting the target rate sensor to turn on doesn't have a consistent power draw. You can specify a weighting which can be applied to each discovered 30 minute slot. This can be specified in a few different ways. Take the following example weighting for a required 2 hours.

1, 1, 2, 1 - This applies a weighting of 1 to the first, second and forth slot and a weighting of 2 to the third slot. This will try and make the cheapest slot fall on the third slot, as long as the surrounding slots are cheaper than other continuous slots. *,2,1 - This applies a weighting of 1 to the first, second and forth slot and a weighting of 2 to the third slot. The can be used as a placeholder for the standard weighting of 1 for all slots before the ones specified. `1,1, 2,- This applies a weighting of 1 to the first, second and forth slot and a weighting of 2 to the third slot. The * can be used as a placeholder for the standard weighting of 1 for all slots after the ones specified. 2,,2` - This applies a weighting of 2 to the first and forth slot and a weighting of 1 to all slots in between. The can be used as a placeholder for the standard weighting of 1 for all slots in between the specified slots.

Extending this, we have

Use Case

The use for me personally is more accurate modelling of how my heat pump consumes energy. I have both under floor heating and DHW generated by the heat pump.

My DHW cycle takes around 1 hour to complete, meaning two slots. The second slot uses about 20% more energy than the first. I'd use a config of 1, 1.2. I currently solve this by having weights 5, 6.

My second use case is when the heat pump is running UFH. I typically have the heating on for 3-5 hours twice a day in winter. The heat pump is slightly less efficient when it starts (in the first period) than the later periods and consumes slightly more electricity. In this case I would want a config to say 1.1, *. I don't see that this use case would be supported otherwise.

Confirmation

henrik-brodtkorb commented 1 day ago

Looking through the source code updating the parsing regex for the weighting is related. https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/blob/ffb8911dd0e6189f1573c5e5677b4a8b238f64af/custom_components/octopus_energy/const.py#L156C8-L156C9

e.g. REGEX_WEIGHTING_NUMBERS = r"([0-9]+(\.[0-9]{1,2})?)"