ulfendk / EnergyAssistant

The Unlicense
3 stars 0 forks source link

started it fails after a while the log always writes #4

Open chirs-51 opened 1 year ago

chirs-51 commented 1 year ago

doesn't always start and if it has started it fails after a while the log always writes

Unhandled exception. System.Collections.Generic.KeyNotFoundException: An index satisfying the predicate was not found in the collection. at Microsoft.FSharp.Collections.ArrayModule.loop@722-39[T](FSharpFunc2 predicate, T[] array, Int32 i) in D:\a\_work\1\s\src\fsharp\FSharp.Core\array.fs:line 723 at Microsoft.FSharp.Collections.ArrayModule.Find[T](FSharpFunc2 predicate, T[] array) in D:\a_work\1\s\src\fsharp\FSharp.Core\array.fs:line 725 at <StartupCode$EnergyAssistant>.$Program.main@() in /src/src/EnergyAssistant/Program.fs:line 224 /run.sh: line 4: 78 Aborted (core dumped) dotnet exec EnergyAssistant.dll /data/options.json

hope the message makes sense

think it's after an update of home assistant

ulfendk commented 1 year ago

I have updated to version 0.66. Today was a mess, data wise as EnergiDataService was down and carnot.dk was testing the new algorithm.

There is some robustness lacking from the code (result of 1 hour here and there programming on it) - but if it fails for me, I do fix it as I rely on it to keep my electricity costs down.

The update has added a isPrediction field to the hourPrices, allowing for better confidence in the numbers.

If you are using ApexChart, you can change the data_generator to return [new Date(start["hour"]).getTime(), entity.attributes.prices[index]["isPrediction"] ? 0 : entity.attributes.prices[index]["price"]]; to show only the confirmed prices from EnergiDataService (public API for accessing Nord Pool data legally).

Please reopen, if you issue persists - I will take a look, just not until later this week.

ulfendk commented 1 year ago

I am now seeing your problem. Hold for a few more minutes.

To get HA to see the update as soon as possible, you need to open the Store (blue button, bottom right on the add-ons page), then click the three dots up right and search for updates.

Will post, when it is fixed in mine, at least.

ulfendk commented 1 year ago

V0.67 is working on mine.

ulfendk commented 1 year ago

But not for long. I will ivestigate tomorrow 😔

chirs-51 commented 1 year ago

after some time its start but fails after some time

s6-rc: info: service s6rc-oneshot-runner: starting s6-rc: info: service s6rc-oneshot-runner successfully started s6-rc: info: service fix-attrs: starting s6-rc: info: service fix-attrs successfully started s6-rc: info: service legacy-cont-init: starting s6-rc: info: service legacy-cont-init successfully started s6-rc: info: service legacy-services: starting s6-rc: info: service legacy-services successfully started Starting Energy Assistant... [2022-11-24 12:00:19] Publishing discovery messages... [2022-11-24 12:00:19] Done [2022-11-24 12:00:19] Downloading predictions from Carnot.dk... [2022-11-24 12:00:20] Downloading spot prices from energidataservice.dk... [2022-11-24 12:00:20] Publishing MQTT states... [2022-11-24 12:00:20] Done [2022-11-24 12:00:21] Sleeping for 00:30:39 minutes [2022-11-24 12:31:00] Downloading predictions from Carnot.dk... [2022-11-24 12:31:01] Downloading spot prices from energidataservice.dk... [2022-11-24 12:31:01] Publishing MQTT states... [2022-11-24 12:31:01] Done [2022-11-24 12:31:02] Sleeping for 00:29:58 minutes [2022-11-24 13:01:00] Downloading predictions from Carnot.dk... [2022-11-24 13:01:00] Downloading spot prices from energidataservice.dk... Unhandled exception. System.Net.WebException: Timeout exceeded while getting response ---> System.TimeoutException: The operation has timed out. at <StartupCode$FSharp-Core>.$Async.AwaitAndBindChildResult@1735-8.Invoke(Boolean _arg4) in D:\a_work\1\s\src\fsharp\FSharp.Core\async.fs:line 1735 at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b](AsyncActivation1 ctxt, b result1, FSharpFunc2 userCode) in D:\a_work\1\s\src\fsharp\FSharp.Core\async.fs:line 465 at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc2 firstAction) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 104 --- End of inner exception stack trace --- at FSharp.Data.HttpHelpers.catchHandler@1-1(HttpWebRequest req, Exception _arg2) at FSharp.Data.HttpHelpers.getResponseAsync@1760-6.Invoke(Exception edi) at Microsoft.FSharp.Control.AsyncPrimitives.CallFilterThenInvoke[T](AsyncActivation1 ctxt, FSharpFunc2 filterFunction, ExceptionDispatchInfo edi) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 487 at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc2 firstAction) in D:\a_work\1\s\src\fsharp\FSharp.Core\async.fs:line 104 --- End of stack trace from previous location --- at Microsoft.FSharp.Control.AsyncResult1.Commit() in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 394 at Microsoft.FSharp.Control.AsyncPrimitives.QueueAsyncAndWaitForResultSynchronously[a](CancellationToken token, FSharpAsync1 computation, FSharpOption1 timeout) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 1045 at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronously[T](CancellationToken cancellationToken, FSharpAsync1 computation, FSharpOption1 timeout) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 1071 at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync1 computation, FSharpOption1 timeout, FSharpOption1 cancellationToken) at <StartupCode$EnergyAssistant>.$Program.main@() in /src/src/EnergyAssistant/Program.fs:line 194 /run.sh: line 4: 77 Aborted (core dumped) dotnet exec EnergyAssistant.dll /data/options.json s6-rc: info: service legacy-services: stopping s6-rc: info: service legacy-services successfully stopped s6-rc: info: service legacy-cont-init: stopping s6-rc: info: service legacy-cont-init successfully stopped s6-rc: info: service fix-attrs: stopping s6-rc: info: service fix-attrs successfully stopped s6-rc: info: service s6rc-oneshot-runner: stopping s6-rc: info: service s6rc-oneshot-runner successfully stopped

ulfendk commented 1 year ago

I need to add some failure handling, such as when energidataservice.dk is down.

However, today I added a failover to Nordpool, when Energidataservice is down, which seems to be the case every other weekend. Hopefully that keeps working, until I get around to a bit more extensive refactoring and stabilization.

Just to be clear: