23 Commits

Author SHA1 Message Date
Pascal Bourque
98003665b8 fix: Build error after TypeScript update (#95) 2025-08-29 08:14:35 -04:00
dependabot[bot]
7afec1a7a9 chore(deps-dev): Bump the dev-dependencies group across 1 directory with 10 updates (#78) 2025-08-29 12:02:56 +00:00
dependabot[bot]
e6631b0fd8 chore(deps): Bump form-data from 4.0.2 to 4.0.4 in the npm_and_yarn group (#69) 2025-08-29 11:56:32 +00:00
dependabot[bot]
efaf3310d2 chore(deps-dev): Bump dotenv from 16.5.0 to 17.2.1 (#71) 2025-08-29 11:56:16 +00:00
dependabot[bot]
a62b538c42 chore(deps-dev): Bump typedoc from 0.28.5 to 0.28.11 (#91) 2025-08-29 11:55:28 +00:00
dependabot[bot]
2023e8b321 chore(deps-dev): Bump @eslint/js from 9.29.0 to 9.34.0 (#92) 2025-08-29 11:55:17 +00:00
dependabot[bot]
808e8f1037 chore(deps-dev): Bump typescript-eslint from 8.35.0 to 8.41.0 (#93) 2025-08-29 11:55:02 +00:00
dependabot[bot]
f201c7944a chore(deps): Bump @aws-sdk/credential-providers from 3.835.0 to 3.876.0 (#94) 2025-08-29 11:54:39 +00:00
dependabot[bot]
f6c6127dab chore(deps): Bump @aws-sdk/credential-providers from 3.830.0 to 3.835.0 (#42) 2025-06-25 14:44:42 +00:00
dependabot[bot]
73cec9a90e chore(deps): Bump aws-iot-device-sdk-v2 from 1.21.5 to 1.22.0 (#40) 2025-06-25 14:41:32 +00:00
dependabot[bot]
39fc9048df chore(deps-dev): Bump typescript-eslint from 8.34.0 to 8.35.0 (#43) 2025-06-25 14:38:35 +00:00
dependabot[bot]
45d69453df chore(deps): Bump @aws-sdk/client-iot from 3.830.0 to 3.835.0 (#44) 2025-06-25 14:38:21 +00:00
Pascal Bourque
6dc6da2dde chore(deps): Updated brace-expansion to fix CVE-2025-5889 (#37) 2025-06-21 10:58:17 -04:00
Pascal Bourque
0cf7a1756c feat(example): Ability to output raw data from the thermostats (#36) 2025-06-21 10:33:08 -04:00
dependabot[bot]
51b8f64dab chore(deps): Bump @aws-sdk/client-iot from 3.826.0 to 3.830.0 (#33) 2025-06-21 13:36:28 +00:00
dependabot[bot]
14ee1d30eb chore(deps-dev): Bump tsx from 4.19.4 to 4.20.3 (#30) 2025-06-21 13:35:23 +00:00
dependabot[bot]
4680ca2f85 chore(deps-dev): Bump @eslint/js from 9.28.0 to 9.29.0 (#32) 2025-06-21 13:35:06 +00:00
dependabot[bot]
3f020d5dc3 chore(deps): Bump @aws-sdk/credential-providers from 3.826.0 to 3.830.0 (#34) 2025-06-21 13:33:25 +00:00
dependabot[bot]
e93741525c chore(deps-dev): Bump the dev-dependencies group across 1 directory with 4 updates (#35) 2025-06-21 13:32:47 +00:00
dependabot[bot]
9b945869aa chore(deps-dev): Bump @types/node from 22.15.30 to 24.0.0 in the dev-dependencies group (#22) 2025-06-10 11:41:22 +00:00
dependabot[bot]
becafbfacc chore(deps-dev): Bump typescript-eslint from 8.33.1 to 8.34.0 (#23) 2025-06-10 11:41:11 +00:00
dependabot[bot]
c29e750f9c chore(deps): Bump @aws-sdk/client-iot from 3.825.0 to 3.826.0 (#20) 2025-06-09 12:34:40 +00:00
dependabot[bot]
e3c93453ed chore(deps): Bump @aws-sdk/credential-providers from 3.825.0 to 3.826.0 (#21) 2025-06-09 12:31:41 +00:00
5 changed files with 1807 additions and 885 deletions

View File

@@ -51,6 +51,12 @@ Then, run the example:
npm run example
```
If you prefer to see the raw data published by your Mysa smart thermostats, run:
```bash
npm run example:raw
```
## Using
The Mysa SDK provides a simple interface to interact with Mysa smart thermostats.

View File

@@ -57,35 +57,41 @@ async function main() {
const devices = await client.getDevices();
client.emitter.on('statusChanged', (status) => {
try {
const device = devices.DevicesObj[status.deviceId];
const watts = status.current !== undefined ? status.current * device.Voltage : undefined;
rootLogger.info(
`'${device.Name}' status changed: ${status.temperature}°C, ${status.humidity}%, ${watts ?? 'na'}W`
);
} catch (error) {
rootLogger.error(`Error processing status update for device '${status.deviceId}':`, error);
}
});
if (process.env.MYSA_OUTPUT_RAW_DATA === 'true') {
client.emitter.on('rawRealtimeMessageReceived', (data) => {
rootLogger.info(data, 'Raw message received');
});
} else {
client.emitter.on('statusChanged', (status) => {
try {
const device = devices.DevicesObj[status.deviceId];
const watts = status.current !== undefined ? status.current * device.Voltage : undefined;
rootLogger.info(
`'${device.Name}' status changed: ${status.temperature}°C, ${status.humidity}%, ${watts ?? 'na'}W`
);
} catch (error) {
rootLogger.error(`Error processing status update for device '${status.deviceId}':`, error);
}
});
client.emitter.on('setPointChanged', (change) => {
try {
const device = devices.DevicesObj[change.deviceId];
rootLogger.info(`'${device.Name}' setpoint changed from ${change.previousSetPoint} to ${change.newSetPoint}`);
} catch (error) {
rootLogger.error(`Error processing setpoint update for device '${change.deviceId}':`, error);
}
});
client.emitter.on('setPointChanged', (change) => {
try {
const device = devices.DevicesObj[change.deviceId];
rootLogger.info(`'${device.Name}' setpoint changed from ${change.previousSetPoint} to ${change.newSetPoint}`);
} catch (error) {
rootLogger.error(`Error processing setpoint update for device '${change.deviceId}':`, error);
}
});
client.emitter.on('stateChanged', (change) => {
try {
const device = devices.DevicesObj[change.deviceId];
rootLogger.info(change, `'${device.Name}' state changed.`);
} catch (error) {
rootLogger.error(`Error processing setpoint update for device '${change.deviceId}':`, error);
}
});
client.emitter.on('stateChanged', (change) => {
try {
const device = devices.DevicesObj[change.deviceId];
rootLogger.info(change, `'${device.Name}' state changed.`);
} catch (error) {
rootLogger.error(`Error processing setpoint update for device '${change.deviceId}':`, error);
}
});
}
for (const device of Object.entries(devices.DevicesObj)) {
const serial = await client.getDeviceSerialNumber(device[0]);

2584
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -40,40 +40,44 @@
"browser": false,
"scripts": {
"example": "tsx --watch ./example/main.ts",
"example:raw": "MYSA_OUTPUT_RAW_DATA=true tsx --watch ./example/main.ts",
"lint": "eslint --max-warnings 0 src/**/*.ts",
"style-lint": "prettier -c .",
"build": "tsup",
"build:docs": "typedoc"
},
"overrides": {
"brace-expansion": "^2.0.2"
},
"dependencies": {
"@aws-sdk/client-iot": "3.825.0",
"@aws-sdk/credential-providers": "3.825.0",
"@aws-sdk/client-iot": "3.835.0",
"@aws-sdk/credential-providers": "3.876.0",
"amazon-cognito-identity-js": "6.3.15",
"aws-iot-device-sdk-v2": "1.21.5",
"aws-iot-device-sdk-v2": "1.22.0",
"dayjs": "1.11.13",
"lodash": "4.17.21"
},
"devDependencies": {
"@eslint/js": "9.28.0",
"@semantic-release/npm": "12.0.1",
"@types/lodash": "4.17.17",
"@types/node": "22.15.30",
"@eslint/js": "9.34.0",
"@semantic-release/npm": "12.0.2",
"@types/lodash": "4.17.20",
"@types/node": "24.3.0",
"conventional-changelog-conventionalcommits": "9.0.0",
"dotenv": "16.5.0",
"eslint": "9.28.0",
"eslint-plugin-jsdoc": "50.7.1",
"dotenv": "17.2.1",
"eslint": "9.34.0",
"eslint-plugin-jsdoc": "54.1.1",
"eslint-plugin-tsdoc": "0.4.0",
"pino": "9.7.0",
"pino-pretty": "13.0.0",
"prettier": "3.5.3",
"prettier-plugin-jsdoc": "1.3.2",
"prettier-plugin-organize-imports": "4.1.0",
"semantic-release": "24.2.5",
"prettier": "3.6.2",
"prettier-plugin-jsdoc": "1.3.3",
"prettier-plugin-organize-imports": "4.2.0",
"semantic-release": "24.2.7",
"tsup": "8.5.0",
"tsx": "4.19.4",
"typedoc": "0.28.5",
"tsx": "4.20.3",
"typedoc": "0.28.11",
"typedoc-material-theme": "1.4.0",
"typescript": "5.8.3",
"typescript-eslint": "8.33.1"
"typescript": "5.9.2",
"typescript-eslint": "8.41.0"
}
}

View File

@@ -32,7 +32,7 @@ export function parseMqttPayload(payload: ArrayBuffer): OutPayload {
* @param payload - The typed payload object to serialize
* @returns The serialized payload as ArrayBuffer ready for MQTT transmission
*/
export function serializeMqttPayload<T extends InPayload>(payload: T): ArrayBuffer {
export function serializeMqttPayload<T extends InPayload>(payload: T): Uint8Array<ArrayBuffer> {
const jsonString = JSON.stringify(payload);
const encoder = new TextEncoder();
return encoder.encode(jsonString);