edilkamin 0.0.2 → 0.0.3

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 CHANGED
@@ -1,3 +1,6 @@
1
1
  declare const deviceInfo: (macAddress: string) => Promise<import("axios").AxiosResponse<any>>;
2
+ declare const setPower: (macAddress: string, value: number) => Promise<import("axios").AxiosResponse<any>>;
3
+ declare const setPowerOn: (macAddress: string) => Promise<import("axios").AxiosResponse<any>>;
4
+ declare const setPowerOff: (macAddress: string) => Promise<import("axios").AxiosResponse<any>>;
2
5
  declare const main: () => void;
3
- export { main, deviceInfo };
6
+ export { main, deviceInfo, setPower, setPowerOff, setPowerOn };
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.deviceInfo = exports.main = void 0;
12
+ exports.setPowerOn = exports.setPowerOff = exports.setPower = exports.deviceInfo = exports.main = void 0;
13
13
  const assert_1 = require("assert");
14
14
  const axios_1 = require("axios");
15
15
  const aws_amplify_1 = require("aws-amplify");
@@ -33,6 +33,13 @@ const signIn = (username, password) => __awaiter(void 0, void 0, void 0, functio
33
33
  });
34
34
  const deviceInfo = (macAddress) => axios_1.default.get(`${constants_1.API_URL}device/${macAddress}/info`);
35
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;
36
43
  const main = () => {
37
44
  const { USERNAME, PASSWORD } = process.env;
38
45
  assert_1.ok(USERNAME);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edilkamin",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -23,6 +23,7 @@
23
23
  },
24
24
  "homepage": "https://github.com/AndreMiras/edilkamin.js#readme",
25
25
  "dependencies": {
26
+ "@aws-amplify/core": "^4.3.14",
26
27
  "aws-amplify": "^4.3.14"
27
28
  },
28
29
  "devDependencies": {