mirror of
https://github.com/bourquep/mysa-js-sdk.git
synced 2026-02-04 01:31:05 +00:00
feat(example): Ability to output raw data from the thermostats (#36)
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -57,6 +57,11 @@ async function main() {
|
||||
|
||||
const devices = await client.getDevices();
|
||||
|
||||
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];
|
||||
@@ -86,6 +91,7 @@ async function main() {
|
||||
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]);
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
"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",
|
||||
|
||||
Reference in New Issue
Block a user