You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sfsw-brown-solar-charger edited this page Mar 8, 2021
·
2 revisions
function myFunction() {
var response = UrlFetchApp.fetch("https://brown-solar-charger-default-rtdb.firebaseio.com/data/liveData.json");
var data=JSON.parse(response.getContentText()); //pull data from the database
var sheet=SpreadsheetApp.getActiveSpreadsheet().getSheetByName("log");
var lastRow=sheet.getLastRow();
var dataline=[[
data["time"],
data["bat%"],
data["WGen"],
data["WUse"],
data["Available"],
data["cumulativeWhGen"]]];
if(sheet.getRange(lastRow,1,1,1).getValue()!=data["time"]){
sheet.getRange(lastRow+1,1,1,6).setValues(dataline);
}
}