I’m on the road atm so wont be able to provide you with everything att.
I can pull 24 different values from nordpool for day, each one of them representing an hourly cost for kWh. If I wish to have my relay on for 4 cheapest hours of day I could pull 4th lowest value from the sorted list of hourly prices and make automation using this price as an price limit.
So that 4th lowest price +0,001€ is the limit and if current price is less then relay ON. (or same results pulling 5th lowest -0,001€)
Using the slider I can choose how many hours i need the relay to be ON per day. If for some reason i want it to be ON all the time then I would choose value 24 (the 24th lowest hour price added with 0,001€) → resulting that every hour meets the criteria and relay is ON for hole day.
What I cant do is to not have it ON at all for the day because if I set the slider to value 0 the value received is for some reason the 24th again. I do not know why.
Meaning that with value 0 it will give same result as with value 24. But if I set slider value to 25 then my result is undefined and end result is that relay will be OFF. That is the only reason I wish to be able to convert value 0 to 25.
Lets face it. I thought that it would be quite simple but it doesnt seem to be that straight forward.
I might have found a different approach for this issue by using this code:
template:
– sensor:
– name: “NordpoolRank”
state: >
{{ (state_attr(‘sensor.nordpool_kwh_fi_eur_3_10_024’, ‘today’) | sort).index(state_attr(‘sensor.nordpool_kwh_fi_eur_3_10_024’, ‘current_price’))+1}}
Creating an automation based on Ranks. Eg, Turn on this when Rank is below X.
But I’m afraid that this will also bring me some problems since I can have an automation based on slider value 1-24h “turn on if rank is below 1” is not intuitive since value 1 would actually mean “0”-hours ON and turn on if rank is below 24 results to 23hours.
So side question. Any idea how to set rule “if below or same”…