mclimate-payload-helper 1.2.3 → 1.2.4
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/decoders/commandsReadingHelper.d.ts.map +1 -1
- package/dist/decoders/commandsReadingHelper.js +124 -44
- package/dist/decoders/commandsReadingHelper.js.map +1 -1
- package/dist/decoders/payloadParsers/index.d.ts +1 -0
- package/dist/decoders/payloadParsers/index.d.ts.map +1 -1
- package/dist/decoders/payloadParsers/index.js +1 -0
- package/dist/decoders/payloadParsers/index.js.map +1 -1
- package/dist/decoders/payloadParsers/multisensorPayloadParser.d.ts +2 -0
- package/dist/decoders/payloadParsers/multisensorPayloadParser.d.ts.map +1 -0
- package/dist/decoders/payloadParsers/multisensorPayloadParser.js +96 -0
- package/dist/decoders/payloadParsers/multisensorPayloadParser.js.map +1 -0
- package/dist/decoders/payloadParsers/types/allDevices.d.ts +2 -1
- package/dist/decoders/payloadParsers/types/allDevices.d.ts.map +1 -1
- package/dist/decoders/payloadParsers/types/allDevices.js +1 -0
- package/dist/decoders/payloadParsers/types/allDevices.js.map +1 -1
- 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/CommandBuilder.d.ts.map +1 -1
- package/dist/encoders/CommandBuilder.js +1 -0
- package/dist/encoders/CommandBuilder.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/MultiSensorCommands.d.ts +25 -0
- package/dist/encoders/MultiSensorCommands.d.ts.map +1 -0
- package/dist/encoders/MultiSensorCommands.js +256 -0
- package/dist/encoders/MultiSensorCommands.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/index.d.ts +1 -0
- package/dist/encoders/index.d.ts.map +1 -1
- package/dist/encoders/index.js +1 -0
- package/dist/encoders/index.js.map +1 -1
- 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/encoders/types/schemas.d.ts +247 -0
- package/dist/encoders/types/schemas.d.ts.map +1 -1
- package/dist/encoders/types/schemas.js +24 -3
- package/dist/encoders/types/schemas.js.map +1 -1
- 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/src/decoders/commandsReadingHelper.ts +283 -204
- package/src/decoders/payloadParsers/index.ts +1 -1
- package/src/decoders/payloadParsers/multisensorPayloadParser.ts +97 -0
- package/src/decoders/payloadParsers/types/allDevices.ts +1 -0
- package/src/encoders/CommandBuilder.ts +2 -0
- package/src/encoders/MultiSensorCommands.ts +253 -0
- package/src/encoders/index.ts +1 -0
- package/src/encoders/types/schemas.ts +62 -9
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { commandsReadingHelper } from '@/decoders'
|
|
2
|
+
import { CustomError } from '@/utils'
|
|
3
|
+
import { DeviceType } from '@/decoders/payloadParsers/types'
|
|
4
|
+
import { byteArrayParser } from '@/helpers'
|
|
5
|
+
|
|
6
|
+
// Multisensor payload parser (uplink). Structure mirrors other parsers in this folder.
|
|
7
|
+
export const multisensorPayloadParser = (hexData: string) => {
|
|
8
|
+
let deviceData: any = {}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
if (!hexData) return
|
|
12
|
+
|
|
13
|
+
const bytes = byteArrayParser(hexData)
|
|
14
|
+
if (!bytes || !bytes.length) return
|
|
15
|
+
|
|
16
|
+
const toHex = (arr: number[]) => arr.map((b) => ('0' + b.toString(16)).slice(-2)).join('')
|
|
17
|
+
|
|
18
|
+
const handleKeepAliveData = (barr: number[]) => {
|
|
19
|
+
// Decode according to provided example indexing
|
|
20
|
+
const b = (i: number, d = 0) => (typeof barr[i] === 'number' ? barr[i] : d)
|
|
21
|
+
|
|
22
|
+
// Byte 1..14 mapping per example
|
|
23
|
+
const deltaTMinC = b(1) / 10
|
|
24
|
+
const deltaTMaxC = b(2) / 10
|
|
25
|
+
const avgTempC = Number((b(3) / 10).toFixed(1))
|
|
26
|
+
const relativeHumidity = b(4)
|
|
27
|
+
// Pressure: matches example (A8 -> 956.94): scale = 390
|
|
28
|
+
const pressureMbar = Number(((b(5) * 390) / 255 + 700).toFixed(2))
|
|
29
|
+
const staticAQI = Number(((b(6) * 500) / 255).toFixed(2))
|
|
30
|
+
// eCO2: matches example (06 -> 508.23): scale = 4600
|
|
31
|
+
const eCO2ppm = Number((((b(7) * 4600) / 255) + 400).toFixed(2))
|
|
32
|
+
const tvocRaw = ((b(8) & 0xff) << 8) | (b(9) & 0xff)
|
|
33
|
+
const tvocPpbApprox = tvocRaw
|
|
34
|
+
const lightLux = Math.round((b(10) * 1000) / 255)
|
|
35
|
+
const noiseDb = b(11)
|
|
36
|
+
const pirTriggerCount = b(12)
|
|
37
|
+
const deviceVoltageMv = Math.round((b(13) * 2200) / 255 + 1600)
|
|
38
|
+
const deviceVoltage = Number((deviceVoltageMv / 1000).toFixed(2))
|
|
39
|
+
const powerSourceRaw = b(14)
|
|
40
|
+
const powerSource = powerSourceRaw === 1 ? 'USB' : 'Battery'
|
|
41
|
+
|
|
42
|
+
const keepaliveData = {
|
|
43
|
+
type: 'keep_alive',
|
|
44
|
+
deltaTMinC,
|
|
45
|
+
deltaTMaxC,
|
|
46
|
+
avgTempC,
|
|
47
|
+
relativeHumidity,
|
|
48
|
+
pressureMbar,
|
|
49
|
+
staticAQI,
|
|
50
|
+
eCO2ppm,
|
|
51
|
+
tvocRaw,
|
|
52
|
+
tvocPpbApprox,
|
|
53
|
+
lightLux,
|
|
54
|
+
noiseDb,
|
|
55
|
+
pirTriggerCount,
|
|
56
|
+
deviceVoltageMv,
|
|
57
|
+
deviceVoltage,
|
|
58
|
+
powerSourceRaw,
|
|
59
|
+
powerSource,
|
|
60
|
+
raw: toHex(barr),
|
|
61
|
+
}
|
|
62
|
+
Object.assign(deviceData, { ...deviceData }, { ...keepaliveData })
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (hexData.slice(0, 2).toLowerCase() === '82') {
|
|
66
|
+
// keep-alive packet
|
|
67
|
+
handleKeepAliveData(bytes)
|
|
68
|
+
} else {
|
|
69
|
+
// parse command answers via helper
|
|
70
|
+
const data = commandsReadingHelper(hexData, 30, DeviceType.MultiSensor)
|
|
71
|
+
if (!data) return
|
|
72
|
+
|
|
73
|
+
const shouldKeepAlive = data.hasOwnProperty('decodeKeepalive') ? true : false
|
|
74
|
+
if ('decodeKeepalive' in data) {
|
|
75
|
+
delete (data as any).decodeKeepalive
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
Object.assign(deviceData, { ...deviceData }, { ...data })
|
|
79
|
+
|
|
80
|
+
// If device response includes keepalive, decode last 15 bytes (30 hex chars)
|
|
81
|
+
if (shouldKeepAlive) {
|
|
82
|
+
const keepaliveHex = hexData.slice(-30)
|
|
83
|
+
const keepaliveBytes = byteArrayParser(keepaliveHex)
|
|
84
|
+
if (keepaliveBytes) handleKeepAliveData(keepaliveBytes)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return deviceData
|
|
89
|
+
} catch (e) {
|
|
90
|
+
throw new CustomError({
|
|
91
|
+
message: `Unhandled data`,
|
|
92
|
+
hexData: hexData,
|
|
93
|
+
deviceType: 'multisensor',
|
|
94
|
+
originalError: e as Error,
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
HTPirLiteCommands,
|
|
21
21
|
Co2PirLiteCommands,
|
|
22
22
|
MelissaCommands,
|
|
23
|
+
MultiSensorCommands,
|
|
23
24
|
} from '@/encoders'
|
|
24
25
|
|
|
25
26
|
import { CustomError, toCamelCase } from '@/utils'
|
|
@@ -50,6 +51,7 @@ export class CommandBuilder {
|
|
|
50
51
|
ht_pir_lite: HTPirLiteCommands,
|
|
51
52
|
co2_pir_lite: Co2PirLiteCommands,
|
|
52
53
|
melissa_lorawan: MelissaCommands,
|
|
54
|
+
multisensor: MultiSensorCommands,
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
57
|
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { BaseCommand, GeneralCommands } from '@/encoders'
|
|
2
|
+
import { ZodError } from 'zod'
|
|
3
|
+
import { CustomError, decToHex, dec2hex } from '@/utils'
|
|
4
|
+
import { MultiSensorCommandTypes, DeviceCommandSchemas } from '@/encoders/types'
|
|
5
|
+
|
|
6
|
+
export class MultiSensorCommands extends GeneralCommands {
|
|
7
|
+
static setLightState(params: MultiSensorCommandTypes.SetLightStateParams) {
|
|
8
|
+
try {
|
|
9
|
+
DeviceCommandSchemas.MultiSensorCommandSchemas.setLightState.parse(params)
|
|
10
|
+
const { enabled } = params
|
|
11
|
+
const enabledValue = enabled ? 1 : 0
|
|
12
|
+
return new BaseCommand('SetLightState', 0x1e, decToHex(enabledValue))
|
|
13
|
+
} catch (e) {
|
|
14
|
+
if (e instanceof ZodError) {
|
|
15
|
+
throw new CustomError({
|
|
16
|
+
message: 'Zod validation error during SetLightState execution',
|
|
17
|
+
command: 'SetLightState',
|
|
18
|
+
originalError: e,
|
|
19
|
+
})
|
|
20
|
+
} else {
|
|
21
|
+
throw new CustomError({
|
|
22
|
+
message: 'Error during SetLightState execution',
|
|
23
|
+
command: 'SetLightState',
|
|
24
|
+
originalError: e as Error,
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static getLightState() {
|
|
31
|
+
return new BaseCommand('GetLightState', 0x1f)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static setHallState(params: MultiSensorCommandTypes.SetHallStateParams) {
|
|
35
|
+
try {
|
|
36
|
+
DeviceCommandSchemas.MultiSensorCommandSchemas.setHallState.parse(params)
|
|
37
|
+
const { enabled } = params
|
|
38
|
+
const enabledValue = enabled ? 1 : 0
|
|
39
|
+
return new BaseCommand('SetHallState', 0x20, decToHex(enabledValue))
|
|
40
|
+
} catch (e) {
|
|
41
|
+
if (e instanceof ZodError) {
|
|
42
|
+
throw new CustomError({
|
|
43
|
+
message: 'Zod validation error during SetHallState execution',
|
|
44
|
+
command: 'SetHallState',
|
|
45
|
+
originalError: e,
|
|
46
|
+
})
|
|
47
|
+
} else {
|
|
48
|
+
throw new CustomError({
|
|
49
|
+
message: 'Error during SetHallState execution',
|
|
50
|
+
command: 'SetHallState',
|
|
51
|
+
originalError: e as Error,
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static getHallState() {
|
|
58
|
+
return new BaseCommand('GetHallState', 0x21)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static setHallBlindPeriod(params: MultiSensorCommandTypes.SetHallBlindPeriodParams) {
|
|
62
|
+
try {
|
|
63
|
+
DeviceCommandSchemas.MultiSensorCommandSchemas.setHallBlindPeriod.parse(params)
|
|
64
|
+
const { period } = params
|
|
65
|
+
return new BaseCommand('SetHallBlindPeriod', 0x22, dec2hex(period))
|
|
66
|
+
} catch (e) {
|
|
67
|
+
if (e instanceof ZodError) {
|
|
68
|
+
throw new CustomError({
|
|
69
|
+
message: 'Zod validation error during SetHallBlindPeriod execution',
|
|
70
|
+
command: 'SetHallBlindPeriod',
|
|
71
|
+
originalError: e,
|
|
72
|
+
})
|
|
73
|
+
} else {
|
|
74
|
+
throw new CustomError({
|
|
75
|
+
message: 'Error during SetHallBlindPeriod execution',
|
|
76
|
+
command: 'SetHallBlindPeriod',
|
|
77
|
+
originalError: e as Error,
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static getHallBlindPeriod() {
|
|
84
|
+
return new BaseCommand('GetHallBlindPeriod', 0x23)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static setMicrophoneState(params: MultiSensorCommandTypes.SetMicrophoneStateParams) {
|
|
88
|
+
try {
|
|
89
|
+
DeviceCommandSchemas.MultiSensorCommandSchemas.setMicrophoneState.parse(params)
|
|
90
|
+
const { enabled } = params
|
|
91
|
+
const enabledValue = enabled ? 1 : 0
|
|
92
|
+
return new BaseCommand('SetMicrophoneState', 0x24, decToHex(enabledValue))
|
|
93
|
+
} catch (e) {
|
|
94
|
+
if (e instanceof ZodError) {
|
|
95
|
+
throw new CustomError({
|
|
96
|
+
message: 'Zod validation error during SetMicrophoneState execution',
|
|
97
|
+
command: 'SetMicrophoneState',
|
|
98
|
+
originalError: e,
|
|
99
|
+
})
|
|
100
|
+
} else {
|
|
101
|
+
throw new CustomError({
|
|
102
|
+
message: 'Error during SetMicrophoneState execution',
|
|
103
|
+
command: 'SetMicrophoneState',
|
|
104
|
+
originalError: e as Error,
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
static getMicrophoneState() {
|
|
111
|
+
return new BaseCommand('GetMicrophoneState', 0x25)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
static setMicrophoneSamplingPeriod(params: MultiSensorCommandTypes.SetMicrophoneSamplingPeriodParams) {
|
|
115
|
+
try {
|
|
116
|
+
DeviceCommandSchemas.MultiSensorCommandSchemas.setMicrophoneSamplingPeriod.parse(params)
|
|
117
|
+
const { period } = params
|
|
118
|
+
return new BaseCommand('SetMicrophoneSamplingPeriod', 0x26, dec2hex(period))
|
|
119
|
+
} catch (e) {
|
|
120
|
+
if (e instanceof ZodError) {
|
|
121
|
+
throw new CustomError({
|
|
122
|
+
message: 'Zod validation error during SetMicrophoneSamplingPeriod execution',
|
|
123
|
+
command: 'SetMicrophoneSamplingPeriod',
|
|
124
|
+
originalError: e,
|
|
125
|
+
})
|
|
126
|
+
} else {
|
|
127
|
+
throw new CustomError({
|
|
128
|
+
message: 'Error during SetMicrophoneSamplingPeriod execution',
|
|
129
|
+
command: 'SetMicrophoneSamplingPeriod',
|
|
130
|
+
originalError: e as Error,
|
|
131
|
+
})
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
static getMicrophoneSamplingPeriod() {
|
|
137
|
+
return new BaseCommand('GetMicrophoneSamplingPeriod', 0x27)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
static setGasState(params: MultiSensorCommandTypes.SetGasStateParams) {
|
|
141
|
+
try {
|
|
142
|
+
DeviceCommandSchemas.MultiSensorCommandSchemas.setGasState.parse(params)
|
|
143
|
+
const { enabled } = params
|
|
144
|
+
const enabledValue = enabled ? 1 : 0
|
|
145
|
+
return new BaseCommand('SetGasState', 0x28, decToHex(enabledValue))
|
|
146
|
+
} catch (e) {
|
|
147
|
+
if (e instanceof ZodError) {
|
|
148
|
+
throw new CustomError({
|
|
149
|
+
message: 'Zod validation error during SetGasState execution',
|
|
150
|
+
command: 'SetGasState',
|
|
151
|
+
originalError: e,
|
|
152
|
+
})
|
|
153
|
+
} else {
|
|
154
|
+
throw new CustomError({
|
|
155
|
+
message: 'Error during SetGasState execution',
|
|
156
|
+
command: 'SetGasState',
|
|
157
|
+
originalError: e as Error,
|
|
158
|
+
})
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
static getGasState() {
|
|
164
|
+
return new BaseCommand('GetGasState', 0x29)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
static setGasMeasurementPeriod(params: MultiSensorCommandTypes.SetGasMeasurementPeriodParams) {
|
|
168
|
+
try {
|
|
169
|
+
DeviceCommandSchemas.MultiSensorCommandSchemas.setGasMeasurementPeriod.parse(params)
|
|
170
|
+
const { minutes } = params
|
|
171
|
+
return new BaseCommand('SetGasMeasurementPeriod', 0x2a, decToHex(minutes))
|
|
172
|
+
} catch (e) {
|
|
173
|
+
if (e instanceof ZodError) {
|
|
174
|
+
throw new CustomError({
|
|
175
|
+
message: 'Zod validation error during SetGasMeasurementPeriod execution',
|
|
176
|
+
command: 'SetGasMeasurementPeriod',
|
|
177
|
+
originalError: e,
|
|
178
|
+
})
|
|
179
|
+
} else {
|
|
180
|
+
throw new CustomError({
|
|
181
|
+
message: 'Error during SetGasMeasurementPeriod execution',
|
|
182
|
+
command: 'SetGasMeasurementPeriod',
|
|
183
|
+
originalError: e as Error,
|
|
184
|
+
})
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
static getGasMeasurementPeriod() {
|
|
190
|
+
return new BaseCommand('GetGasMeasurementPeriod', 0x2b)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
static setPirState(params: MultiSensorCommandTypes.SetPirStateParams) {
|
|
194
|
+
try {
|
|
195
|
+
DeviceCommandSchemas.MultiSensorCommandSchemas.setPirState.parse(params)
|
|
196
|
+
const { enabled } = params
|
|
197
|
+
const enabledValue = enabled ? 1 : 0
|
|
198
|
+
return new BaseCommand('SetPirState', 0x2c, decToHex(enabledValue))
|
|
199
|
+
} catch (e) {
|
|
200
|
+
if (e instanceof ZodError) {
|
|
201
|
+
throw new CustomError({
|
|
202
|
+
message: 'Zod validation error during SetPirState execution',
|
|
203
|
+
command: 'SetPirState',
|
|
204
|
+
originalError: e,
|
|
205
|
+
})
|
|
206
|
+
} else {
|
|
207
|
+
throw new CustomError({
|
|
208
|
+
message: 'Error during SetPirState execution',
|
|
209
|
+
command: 'SetPirState',
|
|
210
|
+
originalError: e as Error,
|
|
211
|
+
})
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
static getPirState() {
|
|
217
|
+
return new BaseCommand('GetPirState', 0x2d)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
static setPirActiveReportingPeriod(params: MultiSensorCommandTypes.SetPirActiveReportingPeriodParams) {
|
|
221
|
+
try {
|
|
222
|
+
DeviceCommandSchemas.MultiSensorCommandSchemas.setPirActiveReportingPeriod.parse(params)
|
|
223
|
+
const { time } = params
|
|
224
|
+
return new BaseCommand('SetPirActiveReportingPeriod', 0x2e, dec2hex(time))
|
|
225
|
+
} catch (e) {
|
|
226
|
+
if (e instanceof ZodError) {
|
|
227
|
+
throw new CustomError({
|
|
228
|
+
message: 'Zod validation error during SetPirActiveReportingPeriod execution',
|
|
229
|
+
command: 'SetPirActiveReportingPeriod',
|
|
230
|
+
originalError: e,
|
|
231
|
+
})
|
|
232
|
+
} else {
|
|
233
|
+
throw new CustomError({
|
|
234
|
+
message: 'Error during SetPirActiveReportingPeriod execution',
|
|
235
|
+
command: 'SetPirActiveReportingPeriod',
|
|
236
|
+
originalError: e as Error,
|
|
237
|
+
})
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
static getPirActiveReportingPeriod() {
|
|
243
|
+
return new BaseCommand('GetPirActiveReportingPeriod', 0x2f)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
static getRegion() {
|
|
247
|
+
return new BaseCommand('GetRegion', 0xa4)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
static restart() {
|
|
251
|
+
return new BaseCommand('Restart', 0xa5)
|
|
252
|
+
}
|
|
253
|
+
}
|
package/src/encoders/index.ts
CHANGED
|
@@ -493,7 +493,7 @@ const VickiCommandSchemas = {
|
|
|
493
493
|
targetTemperature: z.union([
|
|
494
494
|
z.literal(0), // To disable the feature
|
|
495
495
|
z.number().min(5).max(30).multipleOf(0.1), // Temperature range 5.0-30.0°C with 0.1°C increments
|
|
496
|
-
])
|
|
496
|
+
]),
|
|
497
497
|
}),
|
|
498
498
|
setInternalAlgoTemporaryState: z.object({
|
|
499
499
|
enabled: z.boolean(), // true = enable algorithm (00), false = disable algorithm temporarily (01)
|
|
@@ -504,11 +504,11 @@ const VickiCommandSchemas = {
|
|
|
504
504
|
scaleLevel2: z.number().min(5).max(30).multipleOf(0.1),
|
|
505
505
|
scaleLevel3: z.number().min(5).max(30).multipleOf(0.1),
|
|
506
506
|
scaleLevel4: z.number().min(5).max(30).multipleOf(0.1),
|
|
507
|
-
scaleLevel5: z.number().min(5).max(30).multipleOf(0.1)
|
|
507
|
+
scaleLevel5: z.number().min(5).max(30).multipleOf(0.1),
|
|
508
508
|
}),
|
|
509
509
|
setLedIndicationDuration: z.object({
|
|
510
|
-
duration: z.number().min(0.5).max(20).multipleOf(0.5) // Duration in range [0.5:20] with 0.5s resolution
|
|
511
|
-
})
|
|
510
|
+
duration: z.number().min(0.5).max(20).multipleOf(0.5), // Duration in range [0.5:20] with 0.5s resolution
|
|
511
|
+
}),
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
export namespace VickiCommandTypes {
|
|
@@ -1378,8 +1378,6 @@ export namespace Co2PirLiteCommandTypes {
|
|
|
1378
1378
|
export type RestartDeviceParams = z.infer<typeof Co2PirLiteCommandSchemas.restartDevice>
|
|
1379
1379
|
}
|
|
1380
1380
|
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
1381
|
/* --------------------------------------- Melissa --------------------------------------- */
|
|
1384
1382
|
const MelissaCommandSchemas = {
|
|
1385
1383
|
...GeneralCommandSchemas,
|
|
@@ -1389,10 +1387,64 @@ const MelissaCommandSchemas = {
|
|
|
1389
1387
|
}
|
|
1390
1388
|
|
|
1391
1389
|
export namespace MelissaCommandTypes {
|
|
1392
|
-
export type SetIrCodeRecordingParams = z.infer<
|
|
1393
|
-
typeof MelissaCommandSchemas.setIrCodeRecording
|
|
1394
|
-
>
|
|
1390
|
+
export type SetIrCodeRecordingParams = z.infer<typeof MelissaCommandSchemas.setIrCodeRecording>
|
|
1395
1391
|
}
|
|
1392
|
+
|
|
1393
|
+
/* --------------------------------------- MULTISENSOR COMMANDS --------------------------------------- */
|
|
1394
|
+
const MultiSensorCommandSchemas = {
|
|
1395
|
+
...GeneralCommandSchemas,
|
|
1396
|
+
setLightState: z.object({
|
|
1397
|
+
enabled: z.boolean(),
|
|
1398
|
+
}),
|
|
1399
|
+
getLightState: z.object({}),
|
|
1400
|
+
setHallState: z.object({
|
|
1401
|
+
enabled: z.boolean(),
|
|
1402
|
+
}),
|
|
1403
|
+
getHallState: z.object({}),
|
|
1404
|
+
setHallBlindPeriod: z.object({
|
|
1405
|
+
period: z.number().min(0).max(65535),
|
|
1406
|
+
}),
|
|
1407
|
+
getHallBlindPeriod: z.object({}),
|
|
1408
|
+
setMicrophoneState: z.object({
|
|
1409
|
+
enabled: z.boolean(),
|
|
1410
|
+
}),
|
|
1411
|
+
getMicrophoneState: z.object({}),
|
|
1412
|
+
setMicrophoneSamplingPeriod: z.object({
|
|
1413
|
+
period: z.number().min(0).max(65535),
|
|
1414
|
+
}),
|
|
1415
|
+
getMicrophoneSamplingPeriod: z.object({}),
|
|
1416
|
+
setGasState: z.object({
|
|
1417
|
+
enabled: z.boolean(),
|
|
1418
|
+
}),
|
|
1419
|
+
getGasState: z.object({}),
|
|
1420
|
+
setGasMeasurementPeriod: z.object({
|
|
1421
|
+
minutes: z.number().min(0).max(255),
|
|
1422
|
+
}),
|
|
1423
|
+
getGasMeasurementPeriod: z.object({}),
|
|
1424
|
+
setPirState: z.object({
|
|
1425
|
+
enabled: z.boolean(),
|
|
1426
|
+
}),
|
|
1427
|
+
getPirState: z.object({}),
|
|
1428
|
+
setPirActiveReportingPeriod: z.object({
|
|
1429
|
+
time: z.number().min(0).max(65535),
|
|
1430
|
+
}),
|
|
1431
|
+
getPirActiveReportingPeriod: z.object({}),
|
|
1432
|
+
getRegion: z.object({}),
|
|
1433
|
+
restart: z.object({}),
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
export namespace MultiSensorCommandTypes {
|
|
1437
|
+
export type SetLightStateParams = z.infer<typeof MultiSensorCommandSchemas.setLightState>
|
|
1438
|
+
export type SetHallStateParams = z.infer<typeof MultiSensorCommandSchemas.setHallState>
|
|
1439
|
+
export type SetHallBlindPeriodParams = z.infer<typeof MultiSensorCommandSchemas.setHallBlindPeriod>
|
|
1440
|
+
export type SetMicrophoneStateParams = z.infer<typeof MultiSensorCommandSchemas.setMicrophoneState>
|
|
1441
|
+
export type SetMicrophoneSamplingPeriodParams = z.infer<typeof MultiSensorCommandSchemas.setMicrophoneSamplingPeriod>
|
|
1442
|
+
export type SetGasStateParams = z.infer<typeof MultiSensorCommandSchemas.setGasState>
|
|
1443
|
+
export type SetGasMeasurementPeriodParams = z.infer<typeof MultiSensorCommandSchemas.setGasMeasurementPeriod>
|
|
1444
|
+
export type SetPirStateParams = z.infer<typeof MultiSensorCommandSchemas.setPirState>
|
|
1445
|
+
export type SetPirActiveReportingPeriodParams = z.infer<typeof MultiSensorCommandSchemas.setPirActiveReportingPeriod>
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1396
1448
|
/* --------------------------------------- EXPORT ALL SCHEMA GROUPS --------------------------------------- */
|
|
1397
1449
|
export const DeviceCommandSchemas = {
|
|
1398
1450
|
GeneralCommandSchemas,
|
|
@@ -1419,4 +1471,5 @@ export const DeviceCommandSchemas = {
|
|
|
1419
1471
|
HTPirLiteCommandSchemas,
|
|
1420
1472
|
Co2PirLiteCommandSchemas,
|
|
1421
1473
|
MelissaCommandSchemas,
|
|
1474
|
+
MultiSensorCommandSchemas,
|
|
1422
1475
|
}
|