Last active
July 24, 2023 18:16
-
-
Save Olical/25d8b55fce2dd306035af0dac6e0097f to your computer and use it in GitHub Desktop.
Get all meter readings from Switch2 MeterReadings page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For use on https://my.switch2.co.uk/MeterReadings/History | |
// Prints out a CSV which you can save to a file and then upload to something like https://www.csvplot.com/ | |
data = Array.from(document.querySelectorAll(".meter-reading-history-table-data-row.desktop-layout")).map(function (row) { | |
return { | |
date: row.querySelector(".meter-reading-history-table-data-date-row-item").innerText, | |
amount: parseInt(row.querySelector(".meter-reading-history-table-data-amount-row-item").innerText) | |
} | |
}).reverse() | |
console.log("Date,Usage (kWh),Delta (kWh)\n" + data.map((row, index) => { | |
let prev = data[index - 1] | |
return row.date + "," + row.amount + "," + (prev ? row.amount - prev.amount : 0) | |
}).join("\n")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment