/meter-recorder

Fetch temperature periodically from SwitchBot Meter by GAS

Primary LanguageTypeScriptMIT LicenseMIT

meter-recorder

Fetch temperature periodically from SwitchBot Meter Plus by Google Apps Script

Usage

Buy SwitchBot!!

Both Meter and Hub are required to use API.

Don't forget to setup SwitchBot app in your smartphone.

Create Project

$ 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

Deploy Project

$ npm install
$ npm run build
$ clasp push

Create a New SpreadSheet

  • account must be same as where you deployed the project
  • check spreadsheetId (Official Reference)

Set Script Properties

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

Run Script

  • create a time based trigger
  • results are automatically appended to the SpreadSheet!

for Developers

Test

$ npm test

NOTE: You should set environment variables to edit some unittests. Variables are set by dotenv (see .env.example file).

Format soruce codes

$ npm run fmt

Bundle files into dist/

$ npm run build