diff --git a/csharp/App/VrmGrabber/Controller.cs b/csharp/App/VrmGrabber/Controller.cs
index 99aa28ae9..2cac382e7 100644
--- a/csharp/App/VrmGrabber/Controller.cs
+++ b/csharp/App/VrmGrabber/Controller.cs
@@ -127,7 +127,7 @@ th { /* header cell */
⬆️{{FirmwareVersion}} |
";
- var installationsInDb = Db.Installations.ToList();
+ var installationsInDb = Db.Installations.OrderBy(i => i.Name, StringComparer.OrdinalIgnoreCase).ToList();
if (installationsInDb.Count == 0) return new ContentResult
{
ContentType = "text/html",
diff --git a/csharp/App/VrmGrabber/Database/Db.cs b/csharp/App/VrmGrabber/Database/Db.cs
index 50ce83b48..4e4d9c992 100644
--- a/csharp/App/VrmGrabber/Database/Db.cs
+++ b/csharp/App/VrmGrabber/Database/Db.cs
@@ -72,10 +72,12 @@ public static partial class Db
{
sd_notify(0, "WATCHDOG=1");
var user = await GetVrmAccount();
- var installations = await user.GetInstallations();
+ var readOnlyInstallations = await user.GetInstallations();
+
+ var installations = readOnlyInstallations.ToList();
+ installations.Shuffle();
- // var returnDictionary = new Dictionary();
- foreach (var installation in installations) //Todo remove Skip
+ foreach (var installation in installations)
{
Console.WriteLine(installation.Name);
var details = await GetInstallationDetails(installation);
@@ -161,6 +163,8 @@ public static partial class Db
if (lookup == "Unknown")
{
var serial = details.Details.MachineSerial() ?? "Unknown";
+
+ //Todo this seems to be broken? Need to test on Server...
if (serial != "Unknown" && FILE.Exists($@"/etc/openvpn/server/Salino/ccd/{serial}"))
lookup = FILE.ReadAllText($@"/etc/openvpn/server/Salino/ccd/{serial}").Split(' ')[1];
}
diff --git a/csharp/App/VrmGrabber/ShuffleClass.cs b/csharp/App/VrmGrabber/ShuffleClass.cs
new file mode 100644
index 000000000..a52e40cdf
--- /dev/null
+++ b/csharp/App/VrmGrabber/ShuffleClass.cs
@@ -0,0 +1,17 @@
+namespace InnovEnergy.App.VrmGrabber;
+
+public static class ShuffleClass
+{
+ private static readonly Random Rng = new Random();
+
+ public static void Shuffle(this IList list)
+ {
+ var n = list.Count;
+ while (n > 1) {
+ n--;
+ var k = Rng.Next(n + 1);
+ (list[k], list[n]) = (list[n], list[k]);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/csharp/App/VrmGrabber/db.sqlite b/csharp/App/VrmGrabber/db.sqlite
index 30eea1250..e779f5916 100644
Binary files a/csharp/App/VrmGrabber/db.sqlite and b/csharp/App/VrmGrabber/db.sqlite differ
diff --git a/csharp/Lib/Victron/VictronVRM/VrmAccount.cs b/csharp/Lib/Victron/VictronVRM/VrmAccount.cs
index a0e659598..3f2f4689b 100644
--- a/csharp/Lib/Victron/VictronVRM/VrmAccount.cs
+++ b/csharp/Lib/Victron/VictronVRM/VrmAccount.cs
@@ -61,7 +61,7 @@ public class VrmAccount : IDisposable
return vrmReply
.Records
.Select(r => new Installation(this, r!))
- .First();
+ .First(i => i.IdSite == (UInt64)installationId);
}
public void Dispose()