MattJeanes / TeslaMateAgile

Integration to automatically fill in prices for charge data captured by TeslaMate for smart energy providers
MIT License
82 stars 10 forks source link

TeslaMateAgile.PriceHelper Tibber fails #52

Closed Chimpepe closed 5 months ago

Chimpepe commented 7 months ago

Hi Guys,

I'm getting some errors, is this an issue on my side or Tibber?

teslamateagile_1 | info: TeslaMateAgile.PriceHelper[0] teslamateagile_1 | Looking for finished charging processes with no cost set in the 'Home' geofence (id: 1) teslamateagile_1 | info: TeslaMateAgile.PriceHelper[0] teslamateagile_1 | Calculating cost for charges 02/23/2024 08:26:26 UTC - 02/23/2024 08:31:02 UTC teslamateagile_1 | fail: TeslaMateAgile.PriceHelper[0] teslamateagile_1 | Failed to calculate charging cost / energy for charging process 179 teslamateagile_1 | System.Exception: Mismatch of requested price info from Tibber API (expected: 2, actual: 0) teslamateagile_1 | at TeslaMateAgile.Services.TibberService.GetPriceData(DateTimeOffset from, DateTimeOffset to) in /src/TeslaMateAgile/Services/TibberService.cs:line 105 teslamateagile_1 | at TeslaMateAgile.PriceHelper.CalculateChargeCost(IEnumerable`1 charges) in /src/TeslaMateAgile/Helpers/PriceHelper.cs:line 96 teslamateagile_1 | at TeslaMateAgile.PriceHelper.Update() in /src/TeslaMateAgile/Helpers/PriceHelper.cs:line 74

MattJeanes commented 7 months ago

Hi there, this error means that Tibber's API returned no data for the query. I am unfortunately unable to test this myself because I don't have a valid Tibber access token anymore.

If you want to take this to Tibber's support and see what they say, this is the raw GraphQL request that would have been sent:

// POST https://api.tibber.com/v1-beta/gql
{
    "query": "\r\nquery PriceData($after: String, $first: Int) {\r\n    viewer {\r\n        homes {\r\n            currentSubscription {\r\n                priceInfo {\r\n                    range(resolution: HOURLY, after: $after, first: $first) {\r\n                        nodes {\r\n                            total\r\n                            startsAt\r\n                        }\r\n                    }\r\n                    current {\r\n                        total\r\n                        startsAt\r\n                        level\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n",
    "operationName": "PriceData",
    "variables": {
        "after": "MjAyNC0wMi0yM1QwNzoyNjoyNi4wMDAwMDAwKzAwOjAw",
        "first": 2
    }
}

This essentially means, starting at 2024-02-23T07:26:26 (UTC) get me the 2 next prices which should cover the full range of your charging session.

Hope this helps! I could have a look and see what I could find with your access token, but it is a very sensitive thing so you should not really give that out to anyone you don't completely trust.

Chimpepe commented 7 months ago

Thanks! I'll check it. Interesting thing, it's working a one Raspberry Pi4 but not on the Pi5 I'm currently setting up as a replacement for the Pi4. But it's most probably not related to the issue 😅

MattJeanes commented 7 months ago

Pi 4/5 have the same architecture so should be no problem, make sure you're using the latest/same version on both in case it's working on an older version but not on a newer one. Please open a new issue about that one if you need any more help though so we don't clutter this one! 😄

MattJeanes commented 5 months ago

Hi @Chimpepe, did you get a chance to check this out - how did it go?

Chimpepe commented 5 months ago

Hey Matt, sorry for don't getting back to you on this. I don't know why but it works on the next day without any adjustments

MattJeanes commented 5 months ago

Maybe a temporary API issue on Tibber's end then 🤷🏻

Thanks for letting me know, I'll close this issue off then 🙂