dinmammas / homebridge-tibberswitch

Allows you to do automation based on the current electricity price
9 stars 1 forks source link

Best practices for calling Tibber API #1

Closed toini closed 1 year ago

toini commented 1 year ago

Hi!

I would like to thank you for contributing to the community of Tibber users! We've added you to the list of people we respect! https://developer.tibber.com/respect

We noticed your library is polling for prices every ten minutes which is rather not optimal especially if this library gets installed by many people. The prices are updated once per day (around 13 CET) so you could attempt to fetch them often around that time and then stop until the next day?

Also, it looks like you are not setting user-agent header value. You could possibly do that here

A recommended format would be to include both the platform version and driver version like this: 'User-Agent': 'Homebridge/1.2.3 homebridge-tibberswitch/0.0.23'

We're trying to collect best practices here

Let us know if in need of any assistance!

Br, Toni Tibber

dinmammas commented 1 year ago

Hi Toni! Thanks for the kind words.

Improvements are already on the way :)

I'll add caching and refreshing of the data, and headers to the to-do list. It's not gonna be done before next week, I hope that's OK. If not, feel free to do a pull request ;)

Br, David

P.S. It's not my plugin that's listed on the respect page (but that's not important) ;) D.S.

toini commented 1 year ago

We've updated the list now ;)

dinmammas commented 1 year ago

Thnx @toini

I have a beta version ready with the desired changes. I'll let it run for a day or two before I publish to the masses.

dinmammas commented 1 year ago

You should be seeing requests with this user agent now:"User-Agent": "Homebridge/1.5.1 homebridge-tibberswitch/0.2.0 node/16.15.0

toini commented 1 year ago

Awesome!

dinmammas commented 1 year ago

Version 0.3.0 now live.