jpulakka / nordpool_diff

Transforms electricity spot price into thermostat control signal. Home Assistant custom component.
MIT License
63 stars 7 forks source link

New filter type: rank #12

Closed bnordli closed 2 years ago

bnordli commented 2 years ago

Problem

I have set up my water heater to only turn on if nordpool_diff_rectangle_10 > .66. However, on days with low price variation, this never occurs, so the water heater will never turn on.

Solution

If I additionally turn on the water heater if the prices is among the 2 lowest of the next 10 hours, it will also turn on when the (absolute) price variation is small.

There is still a corner case left; when the price is slowly decreasing, so I think I will also have to turn it on if it has stayed off for more than 16 hours (say).

Even though this new filter type is strictly not a FIR differentiator, the framework of retrieving prices was very handy to reuse for this filter, so I hope it is a welcome addition.

jpulakka commented 2 years ago

Thanks for the contribution!

Your 'rank' solution makes good use of existing code and since it solves your (and perhaps someone else's) problem, it's a pragmatic solution to include it in nordpool_diff rather than create yet another custom component doing something almost similar.

It seems to be not only correctly implemented but also properly documented, so I have no problem just merging it.

Regarding heuristics like "I have to turn it on if it has stayed off for more than 16 hours", those probably should be at some layer above nordpool_diff. For example, implemented in HASS sensor templates (template sensors?).