MattJeanes / TeslaMateAgile

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

Failed to update prices - System.ArgumentException: totalHours #43

Closed Flexmaster closed 11 months ago

Flexmaster commented 11 months ago

Hi,

Likely something lame causing this issue, but I just can't figure out what. I'm running teslamate and agile on my Synology DS218+ i a docker container. I assume the issue is related to the TimeZone variable or local DS system time somehow?

teslamateagile: image: mattjeanes/teslamateagile:latest restart: always environment:

And I get the follow output when starting teslamate manually:

docker-teslamateagile-1 | info: TeslaMateAgile.PriceService[0] docker-teslamateagile-1 | Price service is starting docker-teslamateagile-1 | info: TeslaMateAgile.PriceService[0] docker-teslamateagile-1 | Using energy provider Energinet docker-teslamateagile-1 | info: Microsoft.Hosting.Lifetime[0] docker-teslamateagile-1 | Application started. Press Ctrl+C to shut down. docker-teslamateagile-1 | info: Microsoft.Hosting.Lifetime[0] docker-teslamateagile-1 | Hosting environment: Production docker-teslamateagile-1 | info: Microsoft.Hosting.Lifetime[0] docker-teslamateagile-1 | Content root path: /app/ docker-teslamateagile-1 | fail: TeslaMateAgile.PriceService[0] docker-teslamateagile-1 | Failed to update prices docker-teslamateagile-1 | System.ArgumentException: totalHours (Parameter 'Total hours do not equal 24, currently 0') docker-teslamateagile-1 | at TeslaMateAgile.Services.FixedPriceService.GetFixedPrices(FixedPriceOptions options) in /src/TeslaMateAgile/Services/FixedPriceService.cs:line 123 docker-teslamateagile-1 | at TeslaMateAgile.Services.FixedPriceService..ctor(IOptions1 options) in /src/TeslaMateAgile/Services/FixedPriceService.cs:line 18 docker-teslamateagile-1 | at TeslaMateAgile.Services.EnerginetService..ctor(HttpClient client, IOptions1 options) in /src/TeslaMateAgile/Services/EnerginetService.cs:line 23 docker-teslamateagile-1 | at lambda_method1(Closure, IServiceProvider, Object[]) docker-teslamateagile-1 | at Microsoft.Extensions.Http.DefaultTypedHttpClientFactory1.CreateClient(HttpClient httpClient) docker-teslamateagile-1 | at Microsoft.Extensions.DependencyInjection.HttpClientBuilderExtensions.AddTransientHelper[TClient,TImplementation](IServiceProvider s, IHttpClientBuilder builder) docker-teslamateagile-1 | at Microsoft.Extensions.DependencyInjection.HttpClientBuilderExtensions.<>c__DisplayClass13_02.b0(IServiceProvider s) docker-teslamateagile-1 | at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context) docker-teslamateagile-1 | at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) docker-teslamateagile-1 | at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitDisposeCache(ServiceCallSite transientCallSite, RuntimeResolverContext context) docker-teslamateagile-1 | at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) docker-teslamateagile-1 | at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context) docker-teslamateagile-1 | at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) docker-teslamateagile-1 | at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitDisposeCache(ServiceCallSite transientCallSite, RuntimeResolverContext context) docker-teslamateagile-1 | at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) docker-teslamateagile-1 | at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope) docker-teslamateagile-1 | at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>cDisplayClass2_0.b__0(ServiceProviderEngineScope scope) docker-teslamateagile-1 | at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope) docker-teslamateagile-1 | at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType) docker-teslamateagile-1 | at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) docker-teslamateagile-1 | at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) docker-teslamateagile-1 | at TeslaMateAgile.PriceService.DoWork() in /src/TeslaMateAgile/PriceService.cs:line 57 docker-teslamateagile-1 | info: TeslaMateAgile.PriceService[0] docker-teslamateagile-1 | Waiting 300 seconds until next update

MattJeanes commented 11 months ago

Hey, if you only have the one fixed price you can set this natively within the TeslaMate interface under geofences and you don't need TeslaMateAgile.

However if you still want to use it you can try 2 things:

  1. Set the time range to 00:00 - 24:00 (untested)
  2. Add another range e.g. 00:00-12:00 and 12:00-00:00
Flexmaster commented 11 months ago

Hey Matt, Setting the time range to 00:00 - 24:00 seems to work fine and solved the problem :) I use the "EnerginetFixedPricesPrices0" for the static expenses pr. kWh. To my understanding TesmaMateAgile adds the hourly cost for raw electricity (reported by EnergiNet API) to the FixedPrice. A quick test seems to (somewhat ish) match up with this. If I enable the "LoggingLogLevel__Default=Debug" to see the calculations made, where can I find this log?

Thanks for quick reply!

MattJeanes commented 11 months ago

Ah I see! The log goes to stdout so you should be able to view this with the docker logs just like you've posted above

MattJeanes commented 11 months ago

I completely misread your config as I'd just woken up when I saw this 😁 I just saw fixed price and presumed you were using that provider

Flexmaster commented 11 months ago

Well, before the morning coffee (or alike) all mistakes are forgiven! :) Thanks - I found the logs pr. instructed. I need to do some digging with the EnergiNet numbers vs. my supplier/operators hourly numbers. It's close but no cigar as they say.

Thanks a lot Matt for your assistance! And keep up the good work!

MattJeanes commented 11 months ago

Haha true, okay fantastic! I'm gonna close this issue but let me know if you have any more questions 🙂