Skip to content

Commit 80c5b84

Browse files
authored
updated key names to match adafruit
1 parent d260547 commit 80c5b84

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ The APIs will read a default username, feed and key from the [settings](https://
1818

1919
```.env
2020
# env.defaults
21-
AIO_USER=user
22-
AIO_FEED=feed
21+
IO_USER=user
22+
IO_FEED=feed
2323
```
2424

2525
```.env
2626
# env.local
27-
AIO_KEY=...
27+
IO_KEY=...
2828
```
2929

3030
## createData

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "devicescript-adafruit-io",
3-
"version": "0.0.1",
4-
"private": "Minimal adafruit.io REST APIs for DeviceScript",
3+
"version": "0.0.3",
54
"dependencies": {},
65
"devDependencies": {
76
"@devicescript/cli": "latest"

src/index.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@ import { fetch } from "@devicescript/net"
22
import { readSetting } from "@devicescript/settings"
33

44
// read configurations
5-
const defaultFeed = await readSetting("AIO_FEED")
6-
const defaultUser = await readSetting("AIO_USER")
7-
const defaultLat = await readSetting<number>("AIO_LAT")
8-
const defaultLon = await readSetting<number>("AIO_LON")
9-
const defaultEle = await readSetting<number>("AIO_ELE")
10-
const key = await readSetting("AIO_KEY")
5+
const defaultFeed = await readSetting("IO_FEED")
6+
const defaultUser = await readSetting("IO_USER")
7+
const defaultLat = await readSetting<number>("IO_LAT")
8+
const defaultLon = await readSetting<number>("IO_LON")
9+
const defaultEle = await readSetting<number>("IO_ELE")
10+
const key = await readSetting("IO_KEY")
1111

1212
/**
1313
* Creates a data point in a Adafruit.io feed using
1414
* the {@link https://io.adafruit.com/api/docs/#create-data | REST API}
1515
*
1616
* This extension uses the following settings:
1717
*
18-
* - AIO_KEY: (required) access key
19-
* - AIO_FEED: feed name
20-
* - AIO_USER: io.adafruit.com user name
21-
* - AIO_LAT: (optional) latitude (as a number)
22-
* - AIO_LON: (optional) longitude (as a number)
23-
* - AIO_ELE: (optional) elevation (as a number)
18+
* - IO_KEY: (required) access key
19+
* - IO_FEED: feed name
20+
* - IO_USER: io.adafruit.com user name
21+
* - IO_LAT: (optional) latitude (as a number)
22+
* - IO_LON: (optional) longitude (as a number)
23+
* - IO_ELE: (optional) elevation (as a number)
2424
*
2525
* @param value numerical value to upload
2626
* @param options optional latitude longitude
@@ -36,13 +36,13 @@ export async function createData(
3636
ele?: number
3737
}
3838
) {
39-
if (!key) throw new Error("Adafruit.io: missing secret AIO_KEY")
39+
if (!key) throw new Error("Adafruit.io: missing secret IO_KEY")
4040

4141
const { feed, user, lat, lon, ele } = options || {}
4242
const u = user || defaultUser
43-
if (!u) throw new Error("Adafruit.io: missing setting AIO_USER")
43+
if (!u) throw new Error("Adafruit.io: missing setting IO_USER")
4444
const f = feed || defaultFeed
45-
if (!f) throw new Error("Adafruit.io: missing setting AIO_FEED")
45+
if (!f) throw new Error("Adafruit.io: missing setting IO_FEED")
4646

4747
const la = lat || defaultLat
4848
const lo = lon || defaultLon

0 commit comments

Comments
 (0)