gmeks / myUplinkSmartConnect

This program connect to the myuplink.com and adjust the schedule of Høiax CONNECTED hot water heaters, and adjust the schedule so that it uses electricity when the price is low.
8 stars 1 forks source link

myUplinkSmartConnect fails to run #4

Closed KjellRanda closed 1 year ago

KjellRanda commented 1 year ago

Today myUplinkSmartConnect does not run correctly and does not create a new schedule.

It fails with the message: [17:55:54 ERR] Failed to run heater schedule job System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index') at System.Collections.Generic.List1.get_Item(Int32 index) at MyUplinkSmartConnect.CostSavingsRules.RulesBase.GetScheduleTimes(Int32 index) in /data/src/myUplink/CostSavingsRules/RulesBase.cs:line 275 at MyUplinkSmartConnect.CostSavingsRules.RulesBase.CreateLegionellaHeating(DateTime[] datesToSchuedule) in /data/src/myUplink/CostSavingsRules/RulesBase.cs:line 206 at MyUplinkSmartConnect.CostSavingsRules.RulesBase.GenerateRemoteSchedule(String weekFormat, Boolean runLegionellaProgram, IReadOnlyList1 schedule, DateTime[] datesToSchuedule) in /data/src/myUplink/CostSavingsRules/RulesBase.cs:line 87 at MyUplinkSmartConnect.CostSavings.SimplePriceBasedRules.GenerateSchedule(String weekFormat, Boolean runLegionellaHeating, DateTime[] datesToSchuedule) in /data/src/myUplink/CostSavingsRules/SimplePriceBasedRules.cs:line 48 at MyUplinkSmartConnect.JobReScheuleheating.Work() in /data/src/myUplink/JobReScheuleheating.cs:line 93 at MyUplinkSmartConnect.BackgroundJobSupervisor.WorkerSchedule() in /data/src/myUplink/BackgroundJobSupervisor.cs:line 196

This is happening in a docker on RPI 4 that I built a few days ago.

Debug log file attached hoiax.log

KjellRanda commented 1 year ago

I belive I have found the reason for the problem. I had changed the interval between the ligionella heating from 2 to 4 weeks in the myuplink app. Changing it back to two weeks made it run as expected again.

gmeks commented 1 year ago

Nice, il see if i can reproduce that. I did not knwo the ligionlla system was that basic, i thought it was calculated in a bit more scientific way...

One would imagine that the need for running that program would be different if the water is a constant 50c or 60c. I know it resets the counter if you get the water around 70c

That being said, this line of code is clearly the problem. (DateTime starTime, DateTime endTime) result = GetDateTimeFromHourString(WaterHeaterSchedule[index].startTime, WaterHeaterSchedule[index + 1].startTime, WaterHeaterSchedule[index].Date);

I added a likely workaorund in code if you wanna update your Pi image.

KjellRanda commented 1 year ago

Rebuilt the docker and the problem seems to be fixed.

First ran with 2 weeks between legionella heating and got: [21:57:23 DBG] Should try to find schedule for legionella program [21:57:24 DBG] Next legionella program required to run in 316 hours, returning status: False Changed to 4 weeks in the app and restarted the container and no chrash [22:00:16 DBG] Should try to find schedule for legionella program [22:00:16 DBG] Next legionella program required to run in 651 hours, returning status: False

And difference between 651 and 316 hours is close ti two weeks (13.96 days)