TBHV110 to Google Sheet - Private
@dangermikeb
code:
data:privatelast updated:3 years ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 800,000+ developers using the Pipedream platform
steps.
trigger
HTTP API
Deploy to generate unique URL
This workflow runs on Pipedream's servers and is triggered by HTTP / Webhook requests.
steps.
dewpoint_calc_abs
auth
to use OAuth tokens and API keys in code via theauths object
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
}
18
 
var  dewpoint = require('dewpoint');
 
// Dacula is 309m above sea level
var xdp = new dewpoint(309);
 
// t = temperature in °C, rh = rel. humidity in %
//var y = xdp.Calc(event.body.decoded.payload.temp, event.body.decoded.payload.rh);
var y = xdp.Calc(steps.trigger.event.body.decoded.payload.temp_ambient, steps.trigger.event.body.decoded.payload.rh);
var x = y.x; // absolute humidity in g water per kg dry air
var dp = y.dp; // dew point temperature (in °C)
console.dir(x)
return x

//return x;
//return dp;
steps.
dewpoint_calc_dp
auth
to use OAuth tokens and API keys in code via theauths object
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
}
15

var  dewpoint = require('dewpoint');
 
// Dacula is 309m above sea level
var xdp = new dewpoint(309);
 
// t = temperature in °C, rh = rel. humidity in %
//var y = xdp.Calc(event.body.decoded.payload.temp, event.body.decoded.payload.rh);
var y = xdp.Calc(steps.trigger.event.body.decoded.payload.temp_ambient, steps.trigger.event.body.decoded.payload.rh);
var x = y.x; // absolute humidity in g water per kg dry air
var dp = y.dp; // dew point temperature (in °C)
console.dir(dp)
return dp
steps.
C_to_F
auth
to use OAuth tokens and API keys in code via theauths object
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps) => {
1
2
3
4
5
6
7
8
9
10
11
12
}
13
const { toFahrenheitFmt } = require('celsius');
 
//var Ftemp = toFahrenheitFmt(event.body.decoded.payload.temp); // 97
var Ftemp = toFahrenheitFmt(steps.trigger.event.body.decoded.payload.temp_ambient); // 97
console.dir(Ftemp)
return Ftemp

//var dpF = toFahrenheitFmt(steps.dewpoint_calc.dp)
//return [Ftemp, dpF] // returning temp in F and the dewpoint converted to F
//toFahrenheit(36.68, 3); // 98.024
//toFahrenheit('-40.691 degrees C', 5); // -41.24380
steps.
C_to_F_BoardTemp
auth
to use OAuth tokens and API keys in code via theauths object
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps) => {
1
2
3
4
5
6
7
8
9
10
11
12
}
13
const { toFahrenheitFmt } = require('celsius');
 
//var Ftemp = toFahrenheitFmt(event.body.decoded.payload.temp); // 97
var Ftemp = toFahrenheitFmt(event.body.decoded.payload.temp_board); // 97
console.dir(Ftemp)
return Ftemp

//var dpF = toFahrenheitFmt(steps.dewpoint_calc.dp)
//return [Ftemp, dpF] // returning temp in F and the dewpoint converted to F
//toFahrenheit(36.68, 3); // 98.024
//toFahrenheit('-40.691 degrees C', 5); // -41.24380
steps.
C_to_F_dp
auth
to use OAuth tokens and API keys in code via theauths object
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps) => {
1
2
3
4
5
6
7
8
9
10
11
12
}
13
const { toFahrenheitFmt } = require('celsius');
 
//var Ftemp = toFahrenheitFmt(event.body.decoded.payload.temp); // 97
//console.dir(Ftemp)
//return Ftemp

var dpF = toFahrenheitFmt(steps.dewpoint_calc_dp.$return_value)
console.dir(dpF)
return dpF // return dewpoint converted to F
//toFahrenheit(36.68, 3); // 98.024
//toFahrenheit('-40.691 degrees C', 5); // -41.24380
steps.
convert_out_of_unix_time
auth
to use OAuth tokens and API keys in code via theauths object
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps) => {
1
2
3
4
5
6
7
8
9
10
}
11
const UT = require("unixtimejs");

// get current unixtime:
//var ut = UT.now(); // eg: 1517433903
// unixtime -> UTCString
//var utcString = UT.toUTCString(event.body.reported_at); // "Wed, 31 Jan 2018 21:25:03 GMT"
var utcString = UT.toUTCString(event.body.reported_at/1000); // "Wed, 31 Jan 2018 21:25:03 GMT"
console.dir(utcString);
return utcString
steps.
add_single_row_to_sheet
Add a single row of data to Google Sheets
auth
(auths.google_sheets)
params
Columns

Enter the data to insert into each column. Click + to add columns in structured mode, or turn structured mode off to enter array of column values as an expression — e.g., {{[1,2,3]}}

[0]:
 
array ·params.columns
Spreadsheet ID

The spreadsheet ID can be extracted from its URL. E.g., the spreadsheet ID in the URL docs.google.com/spreadsheets/d/abc1234567/edit#gid=0 is abc1234567.

 
1mweDONSnGMtVV1j1-X3NXnkMMnre9IxlTwq8v-rys2E
string ·params.spreadsheetId
Sheet Name

Enter the name of the tab in the spreadsheet where you want to add data. The default name for a new sheet is Sheet1.

 
Sheet1
string ·params.sheetName
code
async (params, auths) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
}
28
const { columns } = params

// validate input
if (!columns || !columns.length) {
  throw new Error("Please enter an array of elements in the `Columns` parameter above")
} else if (!Array.isArray(columns)) {
  throw new Error("Column data is not an array. Please enter an array of elements in the `Columns` parameter above.")
} else if (Array.isArray(columns[0])) {
  throw new Error("Column data is a multi-dimensional array. A one-dimensional is expected. If you're trying to send multiple rows to Google Sheets, search for the action to add multiple rows to Sheets, or try modifying the code for this step.")
}

const config = {
  method: "post",
  url: `https://sheets.googleapis.com/v4/spreadsheets/${params.spreadsheetId}/values/${params.sheetName}:append`,
  params: {
    includeValuesInResponse: true,
    valueInputOption: "USER_ENTERED"
  },
  headers: {
    Authorization: `Bearer ${auths.google_sheets.oauth_access_token}`,
  }, 
  data: {
   values: [columns],
  }
}
return (await require("@pipedreamhq/platform").axios(this, config)).updates
steps.
add_single_row_to_sheet_sensor_compare
Add a single row of data to Google Sheets
auth
(auths.google_sheets)
params
Columns

Enter the data to insert into each column. Click + to add columns in structured mode, or turn structured mode off to enter array of column values as an expression — e.g., {{[1,2,3]}}

[0]:
 
array ·params.columns
Spreadsheet ID

The spreadsheet ID can be extracted from its URL. E.g., the spreadsheet ID in the URL docs.google.com/spreadsheets/d/abc1234567/edit#gid=0 is abc1234567.

 
1mweDONSnGMtVV1j1-X3NXnkMMnre9IxlTwq8v-rys2E
string ·params.spreadsheetId
Sheet Name

Enter the name of the tab in the spreadsheet where you want to add data. The default name for a new sheet is Sheet1.

 
Sheet1
string ·params.sheetName
code
async (params, auths) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
}
28
const { columns } = params

// validate input
if (!columns || !columns.length) {
  throw new Error("Please enter an array of elements in the `Columns` parameter above")
} else if (!Array.isArray(columns)) {
  throw new Error("Column data is not an array. Please enter an array of elements in the `Columns` parameter above.")
} else if (Array.isArray(columns[0])) {
  throw new Error("Column data is a multi-dimensional array. A one-dimensional is expected. If you're trying to send multiple rows to Google Sheets, search for the action to add multiple rows to Sheets, or try modifying the code for this step.")
}

const config = {
  method: "post",
  url: `https://sheets.googleapis.com/v4/spreadsheets/${params.spreadsheetId}/values/${params.sheetName}:append`,
  params: {
    includeValuesInResponse: true,
    valueInputOption: "USER_ENTERED"
  },
  headers: {
    Authorization: `Bearer ${auths.google_sheets.oauth_access_token}`,
  }, 
  data: {
   values: [columns],
  }
}
return (await require("@pipedreamhq/platform").axios(this, config)).updates