Algorithm: Liquid Propane (LP) Tank Level Auto-Logging
This algorithm seeks to assist those living in remote areas to keep track of their propane tank level and usage; allowing them to know when to re-order fuel and not be without heat or hot water during critical times. You will need a device for broadcasting the data via wifi, found here: Tank Utility. (LP tank & wifi device pictured below)
This device comes with a nice iPhone app showing the tank level and trends over time vs. temperature. (screenshots below)
However, the raw data still needs to be extracted form their servers using their Application Programming Interface (API). The code and project steps are listed below to allow any user to perpetually log their unique data & analyze their propane usage over the seasons, understand usage trends & maybe even see if something were awry. Happy coding!
// ***///KEVIN T. JORDAN\\\*** // ***///PROJECT: LIQUID PROPANE TANK AUTO LOGGING ALGORITHM // VERSION 1.0 // NOTES & MANUAL STEPS FOR SETTING UP: //1. GO TO: https://data.tankutility.com/api/getToken // uN: <your user name> // pw: <your password> // curl --user <my_username>:<my_password> https://data.tankutility.com/api/getToken // token // ENTER THIS <my unique token> // curl https://data.tankutility.com/api/devices?token=<my_personal_token> // device // ENTER THIS <my device number> // Record <my device number> and <my unique token> into Atom Text Editor // 2. use template google sheet shared here: https://docs.google.com/spreadsheets/d/1O1In5nguc20KkJYtW3HOnqs9zhm1-fXMDdL4qfHYIQs/edit?usp=sharing // 3. within google sheet, go to Tools>Script Editor // 4. Copy code below "Start Of Algorithm" into Script Editor // 5. replace <my unique token> and <my device number> in the respective locations on line 2 of the script editor // 6. still within google script editor, go to Resources>Current project triggers // 8. add (2) triggers, each between 2-6 hours for both "my function" and "save data" // ***/// START OF ALGORITHM \\\*** function myFunction() { SpreadsheetApp.getActiveSheet().getRange('A1').setValue('=IMPORTDATA("https://data.tankutility.com/api/devices/<my_device_number>?token=<my_unique_token>")') } // custom menu function function onOpen() { var ui = SpreadsheetApp.getUi(); ui.createMenu('Custom Menu') .addItem('Save Data','saveData') .addToUi(); } // function to save data function saveData() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; var name = sheet.getRange('Sheet1!A1').getValue(); var address = sheet.getRange('Sheet1!B1').getValue(); var city = sheet.getRange('Sheet1!C1').getValue(); var state = sheet.getRange('Sheet1!D1').getValue(); var country = sheet.getRange('Sheet1!E1').getValue(); var fuel = sheet.getRange('Sheet1!F1').getValue(); var orientation = sheet.getRange('Sheet1!G1').getValue(); var capacity = sheet.getRange('Sheet1!H1').getValue(); var status = sheet.getRange('Sheet1!I1').getValue(); var reading = sheet.getRange('Sheet1!J1').getValue(); var temperature = sheet.getRange('Sheet1!K1').getValue(); var time = sheet.getRange('Sheet1!L1').getValue(); var timeiso = sheet.getRange('Sheet1!M1').getValue(); sheet.appendRow([name,address,city,state,country,fuel,orientation,capacity,status,reading,temperature,time,timeiso]); }