robinjhector / homebridge-tibber-price

Homebridge plugin for tibber price data
Apache License 2.0
7 stars 1 forks source link

Add option to change behaviour of relative price sensor #109

Closed ThunderFD closed 1 year ago

ThunderFD commented 1 year ago

Is your feature request related to a problem? Please describe: I expected the relative price sensor to be a range between the min and max price of the day, e.g. 0% if the current price is the lowest price of the day and 100% if the current price is the highest price of the day. The Sensor is only relative to the highest price though, so the minimum price may still display as 70% on the sensor. It would be really useful to have the behaviour that I expected to make simple automations that can turn on devices if the electricity is cheap, e.g. relative price < 20%

Describe the solution you'd like: An option to change the behaviour of the relative price sensor OR an option to enable a third sensor that does what I described above so you can have both behaviours at the same time.

I have forked the project and changed the behaviour with 2 lines of code in src/tibber.ts, in getCurrentPriceRelatively():

const minPrice = Math.min(...allPricesForToday);

return ((currPrice - minPrice) / (maxPrice - minPrice)) * 100;

This just changes the current behaviour, so may be undesirable for current users, but it does work.

robinjhector commented 1 year ago

Hi! Thanks for your feature suggestion! 🎉 I completely agree it would make sense to have some kind of 0-100 gauge sensor.

I would vote to add a 3rd sensor for this scenario, and perhaps clarify the behaviour of the current one, instead of changing it.

Would you like to put up a PR for it? Otherwise I could give it a stab in the coming week(s)

ThunderFD commented 1 year ago

Hi, no problem! :)

I have never done anything with Typescript or plugins for any smart home platform so it might be quite the challenge for me. (I was quite confused when I opened the project at first) I might give it a shot if I find the time but don't expect results 😅

robinjhector commented 1 year ago

Hi @ThunderFD ! This should now have been added in v1.1.0! 🎉 Let me know if it works as expected

ThunderFD commented 1 year ago

Hi @ThunderFD ! This should now have been added in v1.1.0! 🎉 Let me know if it works as expected

Hey there! thank you so much for the update! I just reenabled your version of the plugin and uninstalled my fork, so far so good! I'll let you know if anything goes wrong but I doubt it.

Thanks again! 😊