Skip to content

Instantly share code, notes, and snippets.

@Olical
Last active July 24, 2023 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Olical/25d8b55fce2dd306035af0dac6e0097f to your computer and use it in GitHub Desktop.
Save Olical/25d8b55fce2dd306035af0dac6e0097f to your computer and use it in GitHub Desktop.
Get all meter readings from Switch2 MeterReadings page
// 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