edilkamin 0.0.2 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -3
- package/dist/index.js +6 -40
- package/dist/library.d.ts +7 -0
- package/dist/library.js +49 -0
- package/dist/types.d.ts +25 -0
- package/dist/types.js +2 -0
- package/package.json +3 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export { main, deviceInfo };
|
|
1
|
+
export { CommandsType, DeviceInfoType, StatusType, TemperaturesType, UserParametersType, } from "./types";
|
|
2
|
+
export { main, deviceInfo, setPower, setPowerOff, setPowerOn } from "./library";
|
package/dist/index.js
CHANGED
|
@@ -1,42 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
Auth: {
|
|
19
|
-
region: "eu-central-1",
|
|
20
|
-
userPoolId: "eu-central-1_BYmQ2VBlo",
|
|
21
|
-
userPoolWebClientId: "7sc1qltkqobo3ddqsk4542dg2h",
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
aws_amplify_1.Amplify.configure(amplifyconfiguration);
|
|
25
|
-
const signIn = (username, password) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
-
try {
|
|
27
|
-
const user = yield aws_amplify_1.Auth.signIn(username, password);
|
|
28
|
-
console.log("user:", user);
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
console.log("error signing in", error);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
const deviceInfo = (macAddress) => axios_1.default.get(`${constants_1.API_URL}device/${macAddress}/info`);
|
|
35
|
-
exports.deviceInfo = deviceInfo;
|
|
36
|
-
const main = () => {
|
|
37
|
-
const { USERNAME, PASSWORD } = process.env;
|
|
38
|
-
assert_1.ok(USERNAME);
|
|
39
|
-
assert_1.ok(PASSWORD);
|
|
40
|
-
signIn(USERNAME, PASSWORD);
|
|
41
|
-
};
|
|
42
|
-
exports.main = main;
|
|
3
|
+
var library_1 = require("./library");
|
|
4
|
+
Object.defineProperty(exports, "main", { enumerable: true, get: function () { return library_1.main; } });
|
|
5
|
+
Object.defineProperty(exports, "deviceInfo", { enumerable: true, get: function () { return library_1.deviceInfo; } });
|
|
6
|
+
Object.defineProperty(exports, "setPower", { enumerable: true, get: function () { return library_1.setPower; } });
|
|
7
|
+
Object.defineProperty(exports, "setPowerOff", { enumerable: true, get: function () { return library_1.setPowerOff; } });
|
|
8
|
+
Object.defineProperty(exports, "setPowerOn", { enumerable: true, get: function () { return library_1.setPowerOn; } });
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DeviceInfoType } from "./types";
|
|
2
|
+
declare const deviceInfo: (macAddress: string) => Promise<import("axios").AxiosResponse<DeviceInfoType>>;
|
|
3
|
+
declare const setPower: (macAddress: string, value: number) => Promise<import("axios").AxiosResponse<any>>;
|
|
4
|
+
declare const setPowerOn: (macAddress: string) => Promise<import("axios").AxiosResponse<any>>;
|
|
5
|
+
declare const setPowerOff: (macAddress: string) => Promise<import("axios").AxiosResponse<any>>;
|
|
6
|
+
declare const main: () => void;
|
|
7
|
+
export { main, deviceInfo, setPower, setPowerOff, setPowerOn };
|
package/dist/library.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.setPowerOn = exports.setPowerOff = exports.setPower = exports.deviceInfo = exports.main = void 0;
|
|
13
|
+
const assert_1 = require("assert");
|
|
14
|
+
const axios_1 = require("axios");
|
|
15
|
+
const aws_amplify_1 = require("aws-amplify");
|
|
16
|
+
const constants_1 = require("./constants");
|
|
17
|
+
const amplifyconfiguration = {
|
|
18
|
+
Auth: {
|
|
19
|
+
region: "eu-central-1",
|
|
20
|
+
userPoolId: "eu-central-1_BYmQ2VBlo",
|
|
21
|
+
userPoolWebClientId: "7sc1qltkqobo3ddqsk4542dg2h",
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
aws_amplify_1.Amplify.configure(amplifyconfiguration);
|
|
25
|
+
const signIn = (username, password) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
try {
|
|
27
|
+
const user = yield aws_amplify_1.Auth.signIn(username, password);
|
|
28
|
+
console.log("user:", user);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
console.log("error signing in", error);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const deviceInfo = (macAddress) => axios_1.default.get(`${constants_1.API_URL}device/${macAddress}/info`);
|
|
35
|
+
exports.deviceInfo = deviceInfo;
|
|
36
|
+
const mqttCommand = (macAddress, payload) => axios_1.default.put(`${constants_1.API_URL}/mqtt/command`, Object.assign({ mac_address: macAddress }, payload));
|
|
37
|
+
const setPower = (macAddress, value) => mqttCommand(macAddress, { name: "power", value });
|
|
38
|
+
exports.setPower = setPower;
|
|
39
|
+
const setPowerOn = (macAddress) => setPower(macAddress, 1);
|
|
40
|
+
exports.setPowerOn = setPowerOn;
|
|
41
|
+
const setPowerOff = (macAddress) => setPower(macAddress, 0);
|
|
42
|
+
exports.setPowerOff = setPowerOff;
|
|
43
|
+
const main = () => {
|
|
44
|
+
const { USERNAME, PASSWORD } = process.env;
|
|
45
|
+
assert_1.ok(USERNAME);
|
|
46
|
+
assert_1.ok(PASSWORD);
|
|
47
|
+
signIn(USERNAME, PASSWORD);
|
|
48
|
+
};
|
|
49
|
+
exports.main = main;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
interface CommandsType {
|
|
2
|
+
power: boolean;
|
|
3
|
+
}
|
|
4
|
+
interface TemperaturesType {
|
|
5
|
+
board: number;
|
|
6
|
+
enviroment: number;
|
|
7
|
+
}
|
|
8
|
+
interface StatusType {
|
|
9
|
+
commands: CommandsType;
|
|
10
|
+
temperatures: TemperaturesType;
|
|
11
|
+
}
|
|
12
|
+
interface UserParametersType {
|
|
13
|
+
enviroment_1_temperature: number;
|
|
14
|
+
enviroment_2_temperature: number;
|
|
15
|
+
enviroment_3_temperature: number;
|
|
16
|
+
is_auto: boolean;
|
|
17
|
+
is_sound_active: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface DeviceInfoType {
|
|
20
|
+
status: StatusType;
|
|
21
|
+
nvm: {
|
|
22
|
+
user_parameters: UserParametersType;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export type { CommandsType, DeviceInfoType, StatusType, TemperaturesType, UserParametersType, };
|
package/dist/types.js
ADDED
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "edilkamin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
9
|
"lint": "prettier --check src",
|
|
@@ -23,6 +24,7 @@
|
|
|
23
24
|
},
|
|
24
25
|
"homepage": "https://github.com/AndreMiras/edilkamin.js#readme",
|
|
25
26
|
"dependencies": {
|
|
27
|
+
"@aws-amplify/core": "^4.3.14",
|
|
26
28
|
"aws-amplify": "^4.3.14"
|
|
27
29
|
},
|
|
28
30
|
"devDependencies": {
|