From d46096e64042955a42028dbdf6ec4b76475fa7a6 Mon Sep 17 00:00:00 2001 From: Jon Ziebell Date: Sun, 1 Oct 2023 10:27:05 -0400 Subject: [PATCH] Sorted Sensor Detail card by name with thermostat first. --- js/beestat/runtime_sensor.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/js/beestat/runtime_sensor.js b/js/beestat/runtime_sensor.js index 4ab9101..20114b2 100644 --- a/js/beestat/runtime_sensor.js +++ b/js/beestat/runtime_sensor.js @@ -75,6 +75,17 @@ beestat.runtime_sensor.get_data = function(sensor_ids, range, key) { data.metadata.sensors.push(sensor); }); + // Sort by name with the thermostat at the top + data.metadata.sensors.sort(function(a, b) { + if (a.type === 'thermostat') { + return -1; + } else if (b.type === 'thermostat') { + return 1; + } + + return a.name.localeCompare(b.name, 'en', {'sensitivity': 'base'}); + }); + series_codes.push('dummy'); // Initialize a bunch of stuff.