Fetch temperature periodically from SwitchBot Meter Plus by Google Apps Script
Both Meter and Hub are required to use API.
Don't forget to setup SwitchBot app in your smartphone.
$ git clone https://github.com/Syuparn/meter-recorder.git && cd meter-recorder
# set auth to GAS
# (GAS API must be enabled)
$ clasp login --no-localhost
# generate .clasp.json and initialize a project
$ clasp create --rootDir ./dist
$ npm install
$ npm run build
$ clasp push
- account must be same as where you deployed the project
- check
spreadsheetId
(Official Reference)
- open the project
- add script properties below (Official Reference)
property | value |
---|---|
switchbotAuthToken | authentication token for SwitchBot API |
meterDeviceID | deviceID of your SwitchBot Meter, which can be obtained by API |
spreadSheetID | spreadsheetId of SpreadSheet created above |
- create a time based trigger
- results are automatically appended to the SpreadSheet!
$ npm test
NOTE: You should set environment variables to edit some unittests. Variables are set by dotenv (see .env.example
file).
$ npm run fmt
$ npm run build