UPDATE
v5.0.0
This version was first reseased as beta, and now is the time for the offical v5.0.0 release.
Version 4.2 needed quite some bug fixes, sorry about that. In the last week a made a lot of changes based on the feedback of users. So many thanks for that. Keep sending in issues and questions, it will help to improve the macro even more!
Initially I’ve created the macro with only full hours in mind. The price data I worked with (Nordpool) only had hourly data, and the macro only did not really take minutes into account for the setting for the start and end period of the prices to check. In v3.0.0 support for sensors with more than one price per hour was added, and in 4.0.0 support for decimals in the hour setting was added.
Version brings the same support to the start
and end
parameters. You always could enter data which wasn’t a whole hour, but now the data will be converted to actually use that input.
BREAKING CHANGES
- Refactor of
look_ahead
- The way
look_ahead
works has been reworked.look_ahead_minutes
is no longer used, and therefor marked as depreciated in the macro. For now the parameter will be left in, so it will not break you current templates. In v5.0.0 the current time is checked, and converted to a start time shortly before it. To support this, the data in your source sensor is split into smaller parts (minimum of 5 minutes, so 12 parts per hour). So if you enablelook_ahead
and the current time is eg 11:06, the start time for the price selection will be11:10
and there will be 6 data points per hour. If the current time is 12:18, the start time will be12:20
and there will be 3 data points per hour. - In case mode
is_now
is used, the start time will always be set before the current time if it needs to be recalculated. So13:14
will become13:10
. Otherwiseis_now
will never returntrue
after recaculation of thestart
time.
- The way
IMPROVEMENTS
- Both
start
,end
andhours
(optionally defined based onweight
) will be used to split the data,start
,end
andhours
will be adjusted accordingly. If there is a different outcome for one of these parameters, a conversion to 5 minutes (12 datapoints per hour) will be used. Theno_weight_points
parameter can be used to overrule this. When set the setting forno_weight_points
will be used for the adjustments ofstart
,end
andhours
. mode='split
is now a parametersplit
which can be set totrue
orfalse
. So you can now eg usemode='is_now', split=true
to immediately see if the current time is in one of the cheapest blocks. Not all modes work the same as forsplit=false
and this is described in the DATA OUTPUT sectionmode='split'
will still work, and will give the same output assplit=true, mode='all'
- new error messages based on the
start
andend
time are added. There will now be a clear error if thestart
is after theend
and if thehours
setting is higher than the difference betweenstart
andend
- the error message on the number of hours needed, and the hours available has been added
- the error message when there is not enough data is updated, and shows what’s the difference between the data needed, and the available data
- a debug parameter is aded, if set to
true
it will return a dictionary with a lot of data which can be helpful for debugging, including the output based on the other parameters. - if no input for the sensor is provided, the macro will try to find a sensor with the attributes as set for
attr_today
andattr_tomorrow
. So basically if you use the Nordpool integration, or an integration with the same attributes it wil give the start time of the cheapest hour today if you only set usecheapes_energy_hours()
. This can be helpful if for some reason the entity_id changes. Do note that it’s most resource friendly to set the sensor data yourself if it not matches the defaults, so the macro doesn’t have to search for it (the same applies to the attributes and keys). - Lots of code optimization
DOCUMENTATION
- The documentation has been rewritten and a separte HOW TO section has been added.
BUG FIXES
lowest=false
was not working in combination withsplit
, this has been corrected.- the calculation for the
weight
input has been corrected.
Again, if there are any bugs, questions, feature request, please let me know!
What’s Changed
- Refactor start and end conversion to datetime by @TheFes in Refactor start and end conversion to datetime by TheFes · Pull Request #77 · TheFes/cheapest-energy-hours · GitHub
- Add debug setting by @TheFes in Add debug setting by TheFes · Pull Request #78 · TheFes/cheapest-energy-hours · GitHub
- Add sensor finder by @TheFes in Add sensor finder by TheFes · Pull Request #80 · TheFes/cheapest-energy-hours · GitHub
- Refactor time calculations and look_ahead by @TheFes in Refactor time calculations and look_ahead by TheFes · Pull Request #81 · TheFes/cheapest-energy-hours · GitHub
- Refactor mode split to separate setting by @TheFes in Refactor mode split to separate setting by TheFes · Pull Request #82 · TheFes/cheapest-energy-hours · GitHub
- Depreciate datapoints per hour by @TheFes in Depreciate datapoints per hour by TheFes · Pull Request #84 · TheFes/cheapest-energy-hours · GitHub
- several updates by @TheFes in several updates by TheFes · Pull Request #86 · TheFes/cheapest-energy-hours · GitHub
- Fix key finder by @TheFes in Fix key finder by TheFes · Pull Request #87 · TheFes/cheapest-energy-hours · GitHub
- Fix attr find by @TheFes in Fix attr find by TheFes · Pull Request #88 · TheFes/cheapest-energy-hours · GitHub
- Add additoal error messages by @TheFes in Add additoal error messages by TheFes · Pull Request #89 · TheFes/cheapest-energy-hours · GitHub
- Remove microseconds from start and end by @TheFes in Remove microseconds from start and end by TheFes · Pull Request #90 · TheFes/cheapest-energy-hours · GitHub
- Split fixes by @TheFes in Split fixes by TheFes · Pull Request #92 · TheFes/cheapest-energy-hours · GitHub
- fix whitespace issue in output by @TheFes in fix whitespace issue in output by TheFes · Pull Request #93 · TheFes/cheapest-energy-hours · GitHub
- Remove unneeded weight list if no_wp = 1 by @TheFes in Remove unneeded weight list if no_wp = 1 by TheFes · Pull Request #94 · TheFes/cheapest-energy-hours · GitHub
- fix issue because of missing weight by @TheFes in fix issue because of missing weight by TheFes · Pull Request #95 · TheFes/cheapest-energy-hours · GitHub
- Revise weight calculation by @TheFes in Revise weight calculation by TheFes · Pull Request #96 · TheFes/cheapest-energy-hours · GitHub
- Revise time key finder by @TheFes in Revise time key finder by TheFes · Pull Request #97 · TheFes/cheapest-energy-hours · GitHub
- Small typo fixes and clarification by @TheFes in Small typo fixes and clarification by TheFes · Pull Request #98 · TheFes/cheapest-energy-hours · GitHub
- Only use before=true with mode is_now by @TheFes in Only use before=true with mode is_now by TheFes · Pull Request #99 · TheFes/cheapest-energy-hours · GitHub
- Rewrite docs for 5.0.0 by @TheFes in Rewrite docs for 5.0.0 by TheFes · Pull Request #100 · TheFes/cheapest-energy-hours · GitHub
- fix docs titles by @TheFes in fix docs titles by TheFes · Pull Request #101 · TheFes/cheapest-energy-hours · GitHub
Full Changelog: Comparing v4.2.3...v5.0.0 · TheFes/cheapest-energy-hours · GitHub