-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (21 loc) · 824 Bytes
/
index.js
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
29
30
31
32
#!/usr/bin/env node
const { ArgumentParser } = require('argparse');
const { description, version } = require('./package.json');
const { Client } = require('tplink-smarthome-api');
function saveToDisk() {
}
async function main({device, year, month}) {
const client = new Client();
const plug = await client.getDevice({ host: device});
const dailyStats = await plug.emeter.getDayStats(parseInt(year), parseInt(month));
saveToDisk();
console.log(dailyStats);
}
const parser = new ArgumentParser({
description
});
parser.add_argument('-v', '--version', { action: 'version', version });
parser.add_argument('-d', '--device', { help: 'IP of host' });
parser.add_argument('-y', '--year', { help: 'Year' });
parser.add_argument('-m', '--month', { help: 'Month' });
main(parser.parse_args())