Influx Uploading

This commit is contained in:
2024-12-17 21:15:50 -05:00
parent b48eb7fa88
commit a5725edb36
8 changed files with 251 additions and 433 deletions

37
getKey.js Normal file
View File

@@ -0,0 +1,37 @@
import axios from 'axios'
import fs from 'fs'
import meow from 'meow'
let config = JSON.parse(fs.readFileSync('config.json', 'utf8'))
const cli = meow(`
Usage
$ node getKey.js
Options
--force, -f Overwrite existing config.json file
`, {
importMeta: import.meta,
flags: {
force: {
type: 'boolean',
shortFlag: 'f'
}
}
})
if (config.servers.deconz.apiKey.length > 0 && !cli.flags.force) {
console.log("API Key already exists in config.json. Use --force to overwrite.")
process.exit(1)
}
axios.post(config.servers.deconz.url + '/api', {
devicetype: config.servers.deconz.clientName +'l',
})
.then(response => {
console.log("Got API Key, saving to config.json")
config.servers.deconz.apiKey = response.data[0].success.username
fs.writeFileSync('config.json', JSON.stringify(config, null, 2))
}).catch(error => {
console.log("Did you enable API linking in Phoscon?")
console.log(error.status)
})