T3m3z / spotprices2ha

Simple copy-paste approach to fetch data from api.spot-hinta.fi (see https://spot-hinta.fi) to Home Assistant. Includes simple sensors and UI elements to ease automation work.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Night time price (SHF Price2) not working even though times are set

Sappher opened this issue · comments

Hi, and firstly, thank you a great sensor package!

I'm quite new to HA but I've gotten used to the basics and with these sensors I've gotten great tools for different automations. However, it seems like the calculation for night time electricity transfer fees isn't working.

I have set up the variables:
image

But it always just uses the Price1 value, even if time is between 22:00 and 07:00:
image
image
image

I've tried with version 0.11.1 and just updated to 0.2.0 but it still has the same issue.

I took a look at the code for shf_data and it seems like I needed to input the prices other way around: Price1 for night time prices and Price2 for daytime prices. This is because it compares the values as hours and of course in my setup the day changes (between times 22 and 07), making the compare not really valid. I coudln't figure out a clean way to make the compare take this in account either so I just changed the mirrorred the values and it works fine now because day time transfer fee is within a day period (7-22).

So I think this can be closed, maybe update the documentation or if you do find a way to make a reliable compare code - even better!

Great that you found the solution. I added a small section about the correct way of configuring this to the readme file.

And version 0.2.1 now contains validation so that you cannot set the Price2 start/stop wrong way (stop being before start). That should help or at least gently push users into correct direction.