mclimate-payload-helper 1.2.18 → 1.2.19
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 +54 -0
- package/dist/encoders/Co2DisplayCommonCommands.d.ts +0 -4
- package/dist/encoders/Co2DisplayCommonCommands.d.ts.map +1 -1
- package/dist/encoders/Co2DisplayCommonCommands.js +0 -38
- package/dist/encoders/Co2DisplayCommonCommands.js.map +1 -1
- package/dist/encoders/FanCoilThermostat.d.ts +61 -0
- package/dist/encoders/FanCoilThermostat.d.ts.map +1 -0
- package/dist/encoders/FanCoilThermostat.js +719 -0
- package/dist/encoders/FanCoilThermostat.js.map +1 -0
- package/dist/encoders/SetAqiLed.d.ts +6 -0
- package/dist/encoders/SetAqiLed.d.ts.map +1 -0
- package/dist/encoders/SetAqiLed.js +46 -0
- package/dist/encoders/SetAqiLed.js.map +1 -0
- package/dist/encoders/types/enumValidation.d.ts +6 -0
- package/dist/encoders/types/enumValidation.d.ts.map +1 -0
- package/dist/encoders/types/enumValidation.js +50 -0
- package/dist/encoders/types/enumValidation.js.map +1 -0
- package/dist/encoders/types/schemaValidatedEnums.d.ts +40 -0
- package/dist/encoders/types/schemaValidatedEnums.d.ts.map +1 -0
- package/dist/encoders/types/schemaValidatedEnums.js +181 -0
- package/dist/encoders/types/schemaValidatedEnums.js.map +1 -0
- package/dist/types/deviceTypes.d.ts +19 -0
- package/dist/types/deviceTypes.d.ts.map +1 -0
- package/dist/types/deviceTypes.js +23 -0
- package/dist/types/deviceTypes.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +18 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/types.d.ts +13 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +9 -0
- package/dist/types/types.js.map +1 -0
- package/dist/validation.d.ts +3 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +8 -0
- package/dist/validation.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1 +1,55 @@
|
|
|
1
1
|
# mclimate-payload-helper
|
|
2
|
+
|
|
3
|
+
Utilities for working with MClimate IoT device payloads. The package exposes TypeScript helpers to parse uplink payloads, construct downlink command payloads, and reuse the enums/schemas that describe each supported device family.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Typed `uplinkPayloadParser` that converts raw payload buffers into structured data for every supported `DeviceType`.
|
|
8
|
+
- Command builders and enums for devices such as Vicki, Relay 16, TFlood, CO₂ sensors, thermostats, and more.
|
|
9
|
+
- Shared error helpers (`CustomError`) and validation schemas so client apps can keep business logic consistent with the firmware payload contracts.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install mclimate-payload-helper
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The library ships TypeScript declarations, so no extra typings package is required.
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { uplinkPayloadParser, CommandBuilder, DeviceType } from 'mclimate-payload-helper'
|
|
23
|
+
|
|
24
|
+
const uplink = uplinkPayloadParser({
|
|
25
|
+
deviceType: DeviceType.Relay16,
|
|
26
|
+
payloadHex: '0100aa34ff...',
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
const command = new CommandBuilder()
|
|
30
|
+
.forDevice(DeviceType.Vicki)
|
|
31
|
+
.useCommand('setTargetTemperature')
|
|
32
|
+
.withPayload({ temperature: 22 })
|
|
33
|
+
.build()
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Refer to the `src/decoders` and `src/encoders` directories for the complete list of parsers, commands, enums, and helper functions.
|
|
37
|
+
|
|
38
|
+
## Pre-commit hooks
|
|
39
|
+
|
|
40
|
+
Husky enforces repository quality gates before every commit (`.husky/pre-commit`):
|
|
41
|
+
|
|
42
|
+
1. `npm run format:check` – Prettier formatting guard.
|
|
43
|
+
2. `npm run type-check` – Ensures the TypeScript project still compiles.
|
|
44
|
+
3. `npm run lint` – ESLint with the repo ruleset.
|
|
45
|
+
4. `npm run test` – Jest unit tests.
|
|
46
|
+
|
|
47
|
+
If a hook fails, fix the issue locally before committing again.
|
|
48
|
+
|
|
49
|
+
## Publishing a new version
|
|
50
|
+
|
|
51
|
+
1. Bump the version in `package.json` (or run `npm version patch|minor|major` which updates the lockfile and creates a git tag).
|
|
52
|
+
2. Run the full quality suite locally (`npm run format`, `npm run lint`, `npm run type-check`, `npm test`) and ensure `npm run build` succeeds.
|
|
53
|
+
3. Publish the package with `npm publish`. The `prepublishOnly` script will rebuild the dist folder automatically.
|
|
54
|
+
|
|
55
|
+
Skipping the version bump will cause `npm publish` to fail, so always increment the version before publishing.
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { BaseCommand } from '../encoders';
|
|
2
|
-
import { Co2CommonDisplayCommandTypes } from '../encoders/types';
|
|
3
1
|
export declare class Co2DisplayCommonCommands {
|
|
4
|
-
static setCo2ImagesVisibility(params: Co2CommonDisplayCommandTypes.SetCo2ImagesVisibilityParams): BaseCommand;
|
|
5
|
-
static getCo2ImagesVisibility(): BaseCommand;
|
|
6
2
|
}
|
|
7
3
|
//# sourceMappingURL=Co2DisplayCommonCommands.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Co2DisplayCommonCommands.d.ts","sourceRoot":"","sources":["../../src/encoders/Co2DisplayCommonCommands.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Co2DisplayCommonCommands.d.ts","sourceRoot":"","sources":["../../src/encoders/Co2DisplayCommonCommands.ts"],"names":[],"mappings":"AAKA,qBAAa,wBAAwB;CAAG"}
|
|
@@ -1,45 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Co2DisplayCommonCommands = void 0;
|
|
4
|
-
const encoders_1 = require("../encoders");
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
|
-
const utils_1 = require("../utils");
|
|
7
|
-
const types_1 = require("../encoders/types");
|
|
8
4
|
class Co2DisplayCommonCommands {
|
|
9
|
-
static setCo2ImagesVisibility(params) {
|
|
10
|
-
try {
|
|
11
|
-
types_1.DeviceCommandSchemas.Co2CommonDisplayCommandSchemas.setCo2ImagesVisibility.parse(params);
|
|
12
|
-
const { chart, digital_value, emoji } = params;
|
|
13
|
-
const chartValue = chart ? 1 : 0;
|
|
14
|
-
const digitalValue = digital_value ? 1 : 0;
|
|
15
|
-
const emojiValue = emoji ? 1 : 0;
|
|
16
|
-
let bin = '00000000'.split('');
|
|
17
|
-
bin[7] = emojiValue.toString();
|
|
18
|
-
bin[6] = digitalValue.toString();
|
|
19
|
-
bin[5] = chartValue.toString();
|
|
20
|
-
const binValue = parseInt(bin.join(''), 2);
|
|
21
|
-
return new encoders_1.BaseCommand('SetCo2ImagesVisibility', 0x82, (0, utils_1.decToHex)(binValue));
|
|
22
|
-
}
|
|
23
|
-
catch (e) {
|
|
24
|
-
if (e instanceof zod_1.ZodError) {
|
|
25
|
-
throw new utils_1.CustomError({
|
|
26
|
-
message: 'Zod validation error during SetCo2ImagesVisibility execution',
|
|
27
|
-
command: 'SetCo2ImagesVisibility',
|
|
28
|
-
originalError: e,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
throw new utils_1.CustomError({
|
|
33
|
-
message: 'Error during SetCo2ImagesVisibility execution',
|
|
34
|
-
command: 'SetCo2ImagesVisibility',
|
|
35
|
-
originalError: e,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
static getCo2ImagesVisibility() {
|
|
41
|
-
return new encoders_1.BaseCommand('GetCo2ImagesVisibility', 0x83);
|
|
42
|
-
}
|
|
43
5
|
}
|
|
44
6
|
exports.Co2DisplayCommonCommands = Co2DisplayCommonCommands;
|
|
45
7
|
//# sourceMappingURL=Co2DisplayCommonCommands.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Co2DisplayCommonCommands.js","sourceRoot":"","sources":["../../src/encoders/Co2DisplayCommonCommands.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Co2DisplayCommonCommands.js","sourceRoot":"","sources":["../../src/encoders/Co2DisplayCommonCommands.ts"],"names":[],"mappings":";;;AAKA,MAAa,wBAAwB;CAAG;AAAxC,4DAAwC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { BaseCommand } from '../encoders';
|
|
2
|
+
import { FanCoilThermostatCommandTypes } from '../encoders/types';
|
|
3
|
+
export declare class FanCoilThermostatCommands {
|
|
4
|
+
static setTargetTemperatureStep(params: FanCoilThermostatCommandTypes.SetTargetTemperatureStepParams): BaseCommand;
|
|
5
|
+
static getTargetTemperatureStep(): BaseCommand;
|
|
6
|
+
static setKeysLock(params: FanCoilThermostatCommandTypes.SetKeysLockParams): BaseCommand;
|
|
7
|
+
static getKeysLock(): BaseCommand;
|
|
8
|
+
static setFanCoilTarget(params: FanCoilThermostatCommandTypes.SetFanCoilTargetParams): BaseCommand;
|
|
9
|
+
static setTargetTemperature(params: FanCoilThermostatCommandTypes.SetTargetTemperatureFanCoilParams): BaseCommand;
|
|
10
|
+
static setFctOperationalMode(params: FanCoilThermostatCommandTypes.SetFctOperationalModeParams): BaseCommand;
|
|
11
|
+
static setValveOpenCloseTime(params: FanCoilThermostatCommandTypes.SetValveOpenCloseTimeParams): BaseCommand;
|
|
12
|
+
static getValveOpenCloseTime(): BaseCommand;
|
|
13
|
+
static setExtAutomaticTemperatureControl(params: FanCoilThermostatCommandTypes.SetExtAutomaticTemperatureControlParams): BaseCommand;
|
|
14
|
+
static getExtAutomaticTemperatureControl(): BaseCommand;
|
|
15
|
+
static setFanSpeed(params: FanCoilThermostatCommandTypes.SetFanSpeedParams): BaseCommand;
|
|
16
|
+
static getFanSpeed(): BaseCommand;
|
|
17
|
+
static setFanSpeedLimit(params: FanCoilThermostatCommandTypes.SetFanSpeedLimitParams): BaseCommand;
|
|
18
|
+
static getFanSpeedLimit(): BaseCommand;
|
|
19
|
+
static setEcmVoltageRange(params: FanCoilThermostatCommandTypes.SetEcmVoltageRangeParams): BaseCommand;
|
|
20
|
+
static getEcmVoltageRange(): BaseCommand;
|
|
21
|
+
static setEcmStartUpTime(params: FanCoilThermostatCommandTypes.SetEcmStartUpTimeParams): BaseCommand;
|
|
22
|
+
static getEcmStartUpTime(): BaseCommand;
|
|
23
|
+
static setEcmRelay(params: FanCoilThermostatCommandTypes.SetEcmRelayParams): BaseCommand;
|
|
24
|
+
static getEcmRelay(): BaseCommand;
|
|
25
|
+
static setFrostProtection(params: FanCoilThermostatCommandTypes.SetFrostProtectionParams): BaseCommand;
|
|
26
|
+
static getFrostProtection(): BaseCommand;
|
|
27
|
+
static setFrostProtectionSettings(params: FanCoilThermostatCommandTypes.SetFrostProtectionSettingsParams): BaseCommand;
|
|
28
|
+
static getFrostProtectionSettings(): BaseCommand;
|
|
29
|
+
static setAllowedOperationalModes(params: FanCoilThermostatCommandTypes.SetAllowedOperationalModesParams): BaseCommand;
|
|
30
|
+
static getAllowedOperationalModes(): BaseCommand;
|
|
31
|
+
static setCoolingSetpointNotOccupied(params: FanCoilThermostatCommandTypes.SetCoolingSetpointNotOccupiedParams): BaseCommand;
|
|
32
|
+
static getCoolingSetpointNotOccupied(): BaseCommand;
|
|
33
|
+
static setHeatingSetpointNotOccupied(params: FanCoilThermostatCommandTypes.SetHeatingSetpointNotOccupiedParams): BaseCommand;
|
|
34
|
+
static getHeatingSetpointNotOccupied(): BaseCommand;
|
|
35
|
+
static setTempSensorCompensation(params: FanCoilThermostatCommandTypes.SetTempSensorCompensationParams): BaseCommand;
|
|
36
|
+
static getTempSensorCompensation(): BaseCommand;
|
|
37
|
+
static setFanSpeedNotOccupied(params: FanCoilThermostatCommandTypes.SetFanSpeedNotOccupiedParams): BaseCommand;
|
|
38
|
+
static getFanSpeedNotOccupied(): BaseCommand;
|
|
39
|
+
static setAutomaticChangeover(params: FanCoilThermostatCommandTypes.SetAutomaticChangeoverParams): BaseCommand;
|
|
40
|
+
static getAutomaticChangeover(): BaseCommand;
|
|
41
|
+
static setWiringDiagram(params: FanCoilThermostatCommandTypes.SetWiringDiagramParams): BaseCommand;
|
|
42
|
+
static getWiringDiagram(): BaseCommand;
|
|
43
|
+
static setOccFunction(params: FanCoilThermostatCommandTypes.SetOccFunctionParams): BaseCommand;
|
|
44
|
+
static getOccFunction(): BaseCommand;
|
|
45
|
+
static setAutomaticChangeoverThreshold(params: FanCoilThermostatCommandTypes.SetAutomaticChangeoverThresholdParams): BaseCommand;
|
|
46
|
+
static getAutomaticChangeoverThreshold(): BaseCommand;
|
|
47
|
+
static setDeviceStatus(params: FanCoilThermostatCommandTypes.SetDeviceStatusParams): BaseCommand;
|
|
48
|
+
static getDeviceStatus(): BaseCommand;
|
|
49
|
+
static setReturnOfPowerOperation(params: FanCoilThermostatCommandTypes.SetReturnOfPowerOperationParams): BaseCommand;
|
|
50
|
+
static getReturnOfPowerOperation(): BaseCommand;
|
|
51
|
+
static setDeltaTemperature1(params: FanCoilThermostatCommandTypes.SetDeltaTemperature1Params): BaseCommand;
|
|
52
|
+
static getDeltaTemperature1(): BaseCommand;
|
|
53
|
+
static setDeltaTemperature2and3(params: FanCoilThermostatCommandTypes.SetDeltaTemperature2and3Params): BaseCommand;
|
|
54
|
+
static getDeltaTemperature2and3(): BaseCommand;
|
|
55
|
+
static getFrostProtectionStatus(): BaseCommand;
|
|
56
|
+
static getOccupancySensorStatusSetPoint(): BaseCommand;
|
|
57
|
+
static getOccupancySensorStatus(): BaseCommand;
|
|
58
|
+
static getDewPointSensorStatus(): BaseCommand;
|
|
59
|
+
static getFilterAlarm(): BaseCommand;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=FanCoilThermostat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
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