edilkamin 0.0.4 → 1.0.1
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/README.md +7 -3
- package/dist/axios.d.ts +2 -0
- package/dist/axios.js +8 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -0
- package/dist/library.d.ts +10 -6
- package/dist/library.js +23 -19
- package/dist/types.d.ts +16 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
This is a library for the [Reverse Engineered](docs/ReverseEngineering.md) "The Mind" Edilkamin API.
|
|
8
8
|
The Mind offers an app/API to remote control the Edilkamin pellet stoves.
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
## Motivations
|
|
12
11
|
- providing an open source web alternative
|
|
13
12
|
to the [proprietary mobile app](https://play.google.com/store/apps/details?id=com.edilkamin.stufe)
|
|
@@ -16,7 +15,12 @@ The Mind offers an app/API to remote control the Edilkamin pellet stoves.
|
|
|
16
15
|
## Roadmap
|
|
17
16
|
- [x] AWS Amplify/ Cognito authentication
|
|
18
17
|
- [x] unauthenticated endpoint call
|
|
19
|
-
- [
|
|
20
|
-
- [ ] list stoves
|
|
18
|
+
- [x] authenticated endpoint call
|
|
19
|
+
- [ ] ~list stoves~
|
|
21
20
|
- [x] turn stove on/off
|
|
22
21
|
- [ ] set temperature
|
|
22
|
+
|
|
23
|
+
## Limitations
|
|
24
|
+
It seems like there's no endpoint to list stoves associated to a user.
|
|
25
|
+
The way the official app seem to work is by probing the stove via bluetooth.
|
|
26
|
+
Then cache the stove MAC address to a local database for later use.
|
package/dist/axios.d.ts
ADDED
package/dist/axios.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const axios_1 = require("axios");
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
const axiosInstance = axios_1.default.create({
|
|
6
|
+
baseURL: constants_1.API_URL,
|
|
7
|
+
});
|
|
8
|
+
exports.default = axiosInstance;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { DeviceInfoType } from "./types";
|
|
2
|
-
export { main, deviceInfo, setPower, setPowerOff, setPowerOn } from "./library";
|
|
1
|
+
export { CommandsType, DeviceInfoType, StatusType, TemperaturesType, UserParametersType, } from "./types";
|
|
2
|
+
export { signIn, main, deviceInfo, setPower, setPowerOff, setPowerOn, } from "./library";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var library_1 = require("./library");
|
|
4
|
+
Object.defineProperty(exports, "signIn", { enumerable: true, get: function () { return library_1.signIn; } });
|
|
4
5
|
Object.defineProperty(exports, "main", { enumerable: true, get: function () { return library_1.main; } });
|
|
5
6
|
Object.defineProperty(exports, "deviceInfo", { enumerable: true, get: function () { return library_1.deviceInfo; } });
|
|
6
7
|
Object.defineProperty(exports, "setPower", { enumerable: true, get: function () { return library_1.setPower; } });
|
package/dist/library.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { DeviceInfoType } from "./types";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare const
|
|
6
|
-
declare const
|
|
7
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Sign in to return the JWT token.
|
|
4
|
+
*/
|
|
5
|
+
declare const signIn: (username: string, password: string) => Promise<string>;
|
|
6
|
+
declare const deviceInfo: (jwtToken: string, macAddress: string) => Promise<import("axios").AxiosResponse<DeviceInfoType>>;
|
|
7
|
+
declare const setPower: (jwtToken: string, macAddress: string, value: number) => Promise<import("axios").AxiosResponse<any>>;
|
|
8
|
+
declare const setPowerOn: (jwtToken: string, macAddress: string) => Promise<import("axios").AxiosResponse<any>>;
|
|
9
|
+
declare const setPowerOff: (jwtToken: string, macAddress: string) => Promise<import("axios").AxiosResponse<any>>;
|
|
10
|
+
declare const main: () => Promise<void>;
|
|
11
|
+
export { signIn, main, deviceInfo, setPower, setPowerOff, setPowerOn };
|
package/dist/library.js
CHANGED
|
@@ -9,11 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.setPowerOn = exports.setPowerOff = exports.setPower = exports.deviceInfo = exports.main = void 0;
|
|
12
|
+
exports.setPowerOn = exports.setPowerOff = exports.setPower = exports.deviceInfo = exports.main = exports.signIn = void 0;
|
|
13
13
|
const assert_1 = require("assert");
|
|
14
|
-
const axios_1 = require("axios");
|
|
15
14
|
const aws_amplify_1 = require("aws-amplify");
|
|
16
|
-
const
|
|
15
|
+
const axios_1 = require("./axios");
|
|
17
16
|
const amplifyconfiguration = {
|
|
18
17
|
Auth: {
|
|
19
18
|
region: "eu-central-1",
|
|
@@ -22,28 +21,33 @@ const amplifyconfiguration = {
|
|
|
22
21
|
},
|
|
23
22
|
};
|
|
24
23
|
aws_amplify_1.Amplify.configure(amplifyconfiguration);
|
|
24
|
+
const headers = (jwtToken) => ({ Authorization: `Bearer ${jwtToken}` });
|
|
25
|
+
/**
|
|
26
|
+
* Sign in to return the JWT token.
|
|
27
|
+
*/
|
|
25
28
|
const signIn = (username, password) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
29
|
+
const user = yield aws_amplify_1.Auth.signIn(username, password);
|
|
30
|
+
return user.getSignInUserSession().getAccessToken().jwtToken;
|
|
31
|
+
});
|
|
32
|
+
exports.signIn = signIn;
|
|
33
|
+
const deviceInfo = (jwtToken, macAddress) => axios_1.default.get(`device/${macAddress}/info`, {
|
|
34
|
+
headers: headers(jwtToken),
|
|
33
35
|
});
|
|
34
|
-
const deviceInfo = (macAddress) => axios_1.default.get(`${constants_1.API_URL}device/${macAddress}/info`);
|
|
35
36
|
exports.deviceInfo = deviceInfo;
|
|
36
|
-
const mqttCommand = (macAddress, payload) => axios_1.default.put(
|
|
37
|
-
const setPower = (macAddress, value) => mqttCommand(macAddress, { name: "power", value });
|
|
37
|
+
const mqttCommand = (jwtToken, macAddress, payload) => axios_1.default.put(`mqtt/command`, Object.assign({ mac_address: macAddress }, payload), { headers: headers(jwtToken) });
|
|
38
|
+
const setPower = (jwtToken, macAddress, value) => mqttCommand(jwtToken, macAddress, { name: "power", value });
|
|
38
39
|
exports.setPower = setPower;
|
|
39
|
-
const setPowerOn = (macAddress) => setPower(macAddress, 1);
|
|
40
|
+
const setPowerOn = (jwtToken, macAddress) => setPower(jwtToken, macAddress, 1);
|
|
40
41
|
exports.setPowerOn = setPowerOn;
|
|
41
|
-
const setPowerOff = (macAddress) => setPower(macAddress, 0);
|
|
42
|
+
const setPowerOff = (jwtToken, macAddress) => setPower(jwtToken, macAddress, 0);
|
|
42
43
|
exports.setPowerOff = setPowerOff;
|
|
43
|
-
const main = () => {
|
|
44
|
-
const { USERNAME, PASSWORD } = process.env;
|
|
44
|
+
const main = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
const { USERNAME, PASSWORD, MAC_ADDRESS } = process.env;
|
|
45
46
|
assert_1.ok(USERNAME);
|
|
46
47
|
assert_1.ok(PASSWORD);
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
assert_1.ok(MAC_ADDRESS);
|
|
49
|
+
const jwtToken = yield signIn(USERNAME, PASSWORD);
|
|
50
|
+
const info = yield deviceInfo(jwtToken, MAC_ADDRESS);
|
|
51
|
+
console.log({ info });
|
|
52
|
+
});
|
|
49
53
|
exports.main = main;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
interface CommandsType {
|
|
2
2
|
power: boolean;
|
|
3
3
|
}
|
|
4
|
+
interface TemperaturesType {
|
|
5
|
+
board: number;
|
|
6
|
+
enviroment: number;
|
|
7
|
+
}
|
|
4
8
|
interface StatusType {
|
|
5
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;
|
|
6
18
|
}
|
|
7
19
|
interface DeviceInfoType {
|
|
8
20
|
status: StatusType;
|
|
21
|
+
nvm: {
|
|
22
|
+
user_parameters: UserParametersType;
|
|
23
|
+
};
|
|
9
24
|
}
|
|
10
|
-
export type { DeviceInfoType };
|
|
25
|
+
export type { CommandsType, DeviceInfoType, StatusType, TemperaturesType, UserParametersType, };
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "edilkamin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
|
-
"lint": "prettier --check src",
|
|
10
|
-
"format": "prettier --write src",
|
|
9
|
+
"lint": "prettier --check src docs .github",
|
|
10
|
+
"format": "prettier --write src docs .github",
|
|
11
11
|
"build": "tsc"
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@aws-amplify/cli": "^7.6.21",
|
|
32
32
|
"prettier": "^2.5.1",
|
|
33
|
+
"ts-node": "^10.9.1",
|
|
33
34
|
"typedoc": "^0.22.12"
|
|
34
35
|
}
|
|
35
36
|
}
|