mclimate-payload-helper 1.2.19 → 1.2.21
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 +21 -0
- package/dist/decoders/payloadParsers/multisensorPayloadParser.d.ts.map +1 -1
- package/dist/decoders/payloadParsers/multisensorPayloadParser.js +80 -33
- package/dist/decoders/payloadParsers/multisensorPayloadParser.js.map +1 -1
- package/dist/encoders/ButtonCommands.test.d.ts +2 -0
- package/dist/encoders/ButtonCommands.test.d.ts.map +1 -0
- package/dist/encoders/ButtonCommands.test.js +20 -0
- package/dist/encoders/ButtonCommands.test.js.map +1 -0
- package/dist/encoders/ChildLockCommands.test.d.ts +2 -0
- package/dist/encoders/ChildLockCommands.test.d.ts.map +1 -0
- package/dist/encoders/ChildLockCommands.test.js +17 -0
- package/dist/encoders/ChildLockCommands.test.js.map +1 -0
- package/dist/encoders/Co2DisplayCommands.test.d.ts +2 -0
- package/dist/encoders/Co2DisplayCommands.test.d.ts.map +1 -0
- package/dist/encoders/Co2DisplayCommands.test.js +18 -0
- package/dist/encoders/Co2DisplayCommands.test.js.map +1 -0
- package/dist/encoders/Co2DisplayCommonCommands.d.ts +4 -0
- package/dist/encoders/Co2DisplayCommonCommands.d.ts.map +1 -1
- package/dist/encoders/Co2DisplayCommonCommands.js +38 -0
- package/dist/encoders/Co2DisplayCommonCommands.js.map +1 -1
- package/dist/encoders/Co2DisplayLiteCommands.test.d.ts +2 -0
- package/dist/encoders/Co2DisplayLiteCommands.test.d.ts.map +1 -0
- package/dist/encoders/Co2DisplayLiteCommands.test.js +21 -0
- package/dist/encoders/Co2DisplayLiteCommands.test.js.map +1 -0
- package/dist/encoders/Co2PirLiteCommands.test.d.ts +2 -0
- package/dist/encoders/Co2PirLiteCommands.test.d.ts.map +1 -0
- package/dist/encoders/Co2PirLiteCommands.test.js +23 -0
- package/dist/encoders/Co2PirLiteCommands.test.js.map +1 -0
- package/dist/encoders/Co2SensorCommands.test.d.ts +2 -0
- package/dist/encoders/Co2SensorCommands.test.d.ts.map +1 -0
- package/dist/encoders/Co2SensorCommands.test.js +55 -0
- package/dist/encoders/Co2SensorCommands.test.js.map +1 -0
- package/dist/encoders/DisplayCommands.test.d.ts +2 -0
- package/dist/encoders/DisplayCommands.test.d.ts.map +1 -0
- package/dist/encoders/DisplayCommands.test.js +26 -0
- package/dist/encoders/DisplayCommands.test.js.map +1 -0
- package/dist/encoders/DskDeviceCommands.test.d.ts +2 -0
- package/dist/encoders/DskDeviceCommands.test.d.ts.map +1 -0
- package/dist/encoders/DskDeviceCommands.test.js +20 -0
- package/dist/encoders/DskDeviceCommands.test.js.map +1 -0
- package/dist/encoders/FanCoilThermostatCommands.test.d.ts +2 -0
- package/dist/encoders/FanCoilThermostatCommands.test.d.ts.map +1 -0
- package/dist/encoders/FanCoilThermostatCommands.test.js +117 -0
- package/dist/encoders/FanCoilThermostatCommands.test.js.map +1 -0
- package/dist/encoders/GeneralCommands.test.d.ts +2 -0
- package/dist/encoders/GeneralCommands.test.d.ts.map +1 -0
- package/dist/encoders/GeneralCommands.test.js +26 -0
- package/dist/encoders/GeneralCommands.test.js.map +1 -0
- package/dist/encoders/HTDisplayLiteCommands.test.d.ts +2 -0
- package/dist/encoders/HTDisplayLiteCommands.test.d.ts.map +1 -0
- package/dist/encoders/HTDisplayLiteCommands.test.js +20 -0
- package/dist/encoders/HTDisplayLiteCommands.test.js.map +1 -0
- package/dist/encoders/HTPirLiteCommands.test.d.ts +2 -0
- package/dist/encoders/HTPirLiteCommands.test.d.ts.map +1 -0
- package/dist/encoders/HTPirLiteCommands.test.js +23 -0
- package/dist/encoders/HTPirLiteCommands.test.js.map +1 -0
- package/dist/encoders/HTSensorCommands.test.d.ts +2 -0
- package/dist/encoders/HTSensorCommands.test.d.ts.map +1 -0
- package/dist/encoders/HTSensorCommands.test.js +17 -0
- package/dist/encoders/HTSensorCommands.test.js.map +1 -0
- package/dist/encoders/MelissaCommands.test.d.ts +2 -0
- package/dist/encoders/MelissaCommands.test.d.ts.map +1 -0
- package/dist/encoders/MelissaCommands.test.js +14 -0
- package/dist/encoders/MelissaCommands.test.js.map +1 -0
- package/dist/encoders/MultiSensorCommands.test.d.ts +2 -0
- package/dist/encoders/MultiSensorCommands.test.d.ts.map +1 -0
- package/dist/encoders/MultiSensorCommands.test.js +41 -0
- package/dist/encoders/MultiSensorCommands.test.js.map +1 -0
- package/dist/encoders/OpenCloseSensorCommands.test.d.ts +2 -0
- package/dist/encoders/OpenCloseSensorCommands.test.d.ts.map +1 -0
- package/dist/encoders/OpenCloseSensorCommands.test.js +14 -0
- package/dist/encoders/OpenCloseSensorCommands.test.js.map +1 -0
- package/dist/encoders/PIRCommands.test.d.ts +2 -0
- package/dist/encoders/PIRCommands.test.d.ts.map +1 -0
- package/dist/encoders/PIRCommands.test.js +29 -0
- package/dist/encoders/PIRCommands.test.js.map +1 -0
- package/dist/encoders/Relay16Commands.test.d.ts +2 -0
- package/dist/encoders/Relay16Commands.test.d.ts.map +1 -0
- package/dist/encoders/Relay16Commands.test.js +44 -0
- package/dist/encoders/Relay16Commands.test.js.map +1 -0
- package/dist/encoders/Relay16DryCommands.test.d.ts +2 -0
- package/dist/encoders/Relay16DryCommands.test.d.ts.map +1 -0
- package/dist/encoders/Relay16DryCommands.test.js +32 -0
- package/dist/encoders/Relay16DryCommands.test.js.map +1 -0
- package/dist/encoders/SetAqiLedCommands.test.d.ts +2 -0
- package/dist/encoders/SetAqiLedCommands.test.d.ts.map +1 -0
- package/dist/encoders/SetAqiLedCommands.test.js +20 -0
- package/dist/encoders/SetAqiLedCommands.test.js.map +1 -0
- package/dist/encoders/TFloodCommands.test.d.ts +2 -0
- package/dist/encoders/TFloodCommands.test.d.ts.map +1 -0
- package/dist/encoders/TFloodCommands.test.js +23 -0
- package/dist/encoders/TFloodCommands.test.js.map +1 -0
- package/dist/encoders/TRingThermostatCommands.test.d.ts +2 -0
- package/dist/encoders/TRingThermostatCommands.test.d.ts.map +1 -0
- package/dist/encoders/TRingThermostatCommands.test.js +16 -0
- package/dist/encoders/TRingThermostatCommands.test.js.map +1 -0
- package/dist/encoders/TValveCommands.test.d.ts +2 -0
- package/dist/encoders/TValveCommands.test.d.ts.map +1 -0
- package/dist/encoders/TValveCommands.test.js +56 -0
- package/dist/encoders/TValveCommands.test.js.map +1 -0
- package/dist/encoders/TemperatureCommonCommands.test.d.ts +2 -0
- package/dist/encoders/TemperatureCommonCommands.test.d.ts.map +1 -0
- package/dist/encoders/TemperatureCommonCommands.test.js +14 -0
- package/dist/encoders/TemperatureCommonCommands.test.js.map +1 -0
- package/dist/encoders/VickiCommands.test.d.ts +2 -0
- package/dist/encoders/VickiCommands.test.d.ts.map +1 -0
- package/dist/encoders/VickiCommands.test.js +156 -0
- package/dist/encoders/VickiCommands.test.js.map +1 -0
- package/dist/encoders/WirelessThermostatCommands.test.d.ts +2 -0
- package/dist/encoders/WirelessThermostatCommands.test.d.ts.map +1 -0
- package/dist/encoders/WirelessThermostatCommands.test.js +41 -0
- package/dist/encoders/WirelessThermostatCommands.test.js.map +1 -0
- package/dist/test/payloadDecoders.test.js +34 -34
- package/dist/test/payloadDecoders.test.js.map +1 -1
- package/package.json +1 -1
- package/src/decoders/payloadParsers/multisensorPayloadParser.ts +96 -34
- package/src/encoders/ButtonCommands.test.ts +26 -0
- package/src/encoders/ChildLockCommands.test.ts +22 -0
- package/src/encoders/Co2DisplayCommands.test.ts +26 -0
- package/src/encoders/Co2DisplayLiteCommands.test.ts +30 -0
- package/src/encoders/Co2PirLiteCommands.test.ts +32 -0
- package/src/encoders/Co2SensorCommands.test.ts +79 -0
- package/src/encoders/DisplayCommands.test.ts +40 -0
- package/src/encoders/DskDeviceCommands.test.ts +26 -0
- package/src/encoders/FanCoilThermostatCommands.test.ts +204 -0
- package/src/encoders/GeneralCommands.test.ts +38 -0
- package/src/encoders/HTDisplayLiteCommands.test.ts +28 -0
- package/src/encoders/HTPirLiteCommands.test.ts +32 -0
- package/src/encoders/HTSensorCommands.test.ts +24 -0
- package/src/encoders/MelissaCommands.test.ts +16 -0
- package/src/encoders/MultiSensorCommands.test.ts +68 -0
- package/src/encoders/OpenCloseSensorCommands.test.ts +16 -0
- package/src/encoders/PIRCommands.test.ts +46 -0
- package/src/encoders/Relay16Commands.test.ts +76 -0
- package/src/encoders/Relay16DryCommands.test.ts +52 -0
- package/src/encoders/SetAqiLedCommands.test.ts +18 -0
- package/src/encoders/TFloodCommands.test.ts +34 -0
- package/src/encoders/TRingThermostatCommands.test.ts +23 -0
- package/src/encoders/TValveCommands.test.ts +98 -0
- package/src/encoders/TemperatureCommonCommands.test.ts +16 -0
- package/src/encoders/VickiCommands.test.ts +275 -0
- package/src/encoders/WirelessThermostatCommands.test.ts +70 -0
- package/src/test/payloadDecoders.test.ts +34 -34
- package/src/test.txt +1 -0
- package/dist/encoders/FanCoilThermostat.d.ts +0 -61
- package/dist/encoders/FanCoilThermostat.d.ts.map +0 -1
- package/dist/encoders/FanCoilThermostat.js +0 -719
- package/dist/encoders/FanCoilThermostat.js.map +0 -1
- package/dist/encoders/SetAqiLed.d.ts +0 -6
- package/dist/encoders/SetAqiLed.d.ts.map +0 -1
- package/dist/encoders/SetAqiLed.js +0 -46
- package/dist/encoders/SetAqiLed.js.map +0 -1
- package/dist/encoders/types/enumValidation.d.ts +0 -6
- package/dist/encoders/types/enumValidation.d.ts.map +0 -1
- package/dist/encoders/types/enumValidation.js +0 -50
- package/dist/encoders/types/enumValidation.js.map +0 -1
- package/dist/encoders/types/schemaValidatedEnums.d.ts +0 -40
- package/dist/encoders/types/schemaValidatedEnums.d.ts.map +0 -1
- package/dist/encoders/types/schemaValidatedEnums.js +0 -181
- package/dist/encoders/types/schemaValidatedEnums.js.map +0 -1
- package/dist/types/deviceTypes.d.ts +0 -19
- package/dist/types/deviceTypes.d.ts.map +0 -1
- package/dist/types/deviceTypes.js +0 -23
- package/dist/types/deviceTypes.js.map +0 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -18
- package/dist/types/index.js.map +0 -1
- package/dist/types/types.d.ts +0 -13
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/types.js +0 -9
- package/dist/types/types.js.map +0 -1
- package/dist/validation.d.ts +0 -3
- package/dist/validation.d.ts.map +0 -1
- package/dist/validation.js +0 -8
- package/dist/validation.js.map +0 -1
- package/src/test/payloadEncoders.test.ts +0 -850
|
@@ -1,850 +0,0 @@
|
|
|
1
|
-
import { CommandBuilder, BaseCommand } from '@/encoders'
|
|
2
|
-
import { CustomError } from '@/utils'
|
|
3
|
-
|
|
4
|
-
describe('General Commands payload encoder', () => {
|
|
5
|
-
const commandBuilder = new CommandBuilder('vicki')
|
|
6
|
-
|
|
7
|
-
test('Custom hex command Vicki', () => {
|
|
8
|
-
expect(commandBuilder.build('SendCustomHexCommand', { command: '0412' })).toStrictEqual(
|
|
9
|
-
new BaseCommand('SendCustomHexCommand', '0412'),
|
|
10
|
-
)
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
test('Set keepalive time', () => {
|
|
14
|
-
expect(commandBuilder.build('SetKeepAlive', { time: 5 })).toStrictEqual(new BaseCommand('SetKeepAlive', 2, '05'))
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
test('Set heating event (weekend)', () => {
|
|
18
|
-
//5900080101021F
|
|
19
|
-
expect(
|
|
20
|
-
commandBuilder.build('SetHeatingEvent', {
|
|
21
|
-
eventIndex: 0,
|
|
22
|
-
startHour: 8,
|
|
23
|
-
startMinute: 1,
|
|
24
|
-
targetTemperature: 25.8,
|
|
25
|
-
daysActive: {
|
|
26
|
-
monday: true,
|
|
27
|
-
tuesday: true,
|
|
28
|
-
wednesday: true,
|
|
29
|
-
thursday: true,
|
|
30
|
-
friday: true,
|
|
31
|
-
saturday: false,
|
|
32
|
-
sunday: false,
|
|
33
|
-
},
|
|
34
|
-
}),
|
|
35
|
-
).toStrictEqual(new BaseCommand('SetHeatingEvent', 0x59, '00', '08', '01', '0102', '1F'))
|
|
36
|
-
})
|
|
37
|
-
test('Set heating event', () => {
|
|
38
|
-
//59020600006460
|
|
39
|
-
expect(
|
|
40
|
-
commandBuilder.build('SetHeatingEvent', {
|
|
41
|
-
eventIndex: 2,
|
|
42
|
-
startHour: 6,
|
|
43
|
-
startMinute: 0,
|
|
44
|
-
targetTemperature: 5.0,
|
|
45
|
-
daysActive: {
|
|
46
|
-
monday: false,
|
|
47
|
-
tuesday: false,
|
|
48
|
-
wednesday: false,
|
|
49
|
-
thursday: false,
|
|
50
|
-
friday: false,
|
|
51
|
-
saturday: true,
|
|
52
|
-
sunday: true,
|
|
53
|
-
},
|
|
54
|
-
}),
|
|
55
|
-
).toStrictEqual(new BaseCommand('SetHeatingEvent', 0x59, '02', '06', '00', '0032', '60'))
|
|
56
|
-
})
|
|
57
|
-
test('Activate heating event (index 16)', () => {
|
|
58
|
-
expect(commandBuilder.build('SetHeatingEventState', { eventIndex: 16, active: true })).toStrictEqual(
|
|
59
|
-
new BaseCommand('SetHeatingEventState', 0x6b, '10', '01'),
|
|
60
|
-
)
|
|
61
|
-
})
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
describe('TValve commands payload encoder', () => {
|
|
65
|
-
const commandBuilder = new CommandBuilder('t_valve')
|
|
66
|
-
|
|
67
|
-
test('Set open close command', () => {
|
|
68
|
-
expect(commandBuilder.build('SetOpenCloseTime', { openingTime: 1, closingTime: 5 })).toStrictEqual(
|
|
69
|
-
new BaseCommand('SetOpenCloseTime', 1, '01', '05'),
|
|
70
|
-
)
|
|
71
|
-
})
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
describe('Relay commands payload encoder', () => {
|
|
75
|
-
const commandBuilder = new CommandBuilder('relay_16')
|
|
76
|
-
|
|
77
|
-
test('SetRelayState command', () => {
|
|
78
|
-
expect(commandBuilder.build('SetRelayState', { state: true })).toStrictEqual(
|
|
79
|
-
new BaseCommand('SetRelayState', 0xc1, '01'),
|
|
80
|
-
)
|
|
81
|
-
})
|
|
82
|
-
test('SetRelayTimerInMilliseconds command', () => {
|
|
83
|
-
expect(commandBuilder.build('SetRelayTimerInMilliseconds', { state: 0, time: 500 })).toStrictEqual(
|
|
84
|
-
new BaseCommand('SetRelayTimerInMilliseconds', 0x55, '00', '01F4'),
|
|
85
|
-
)
|
|
86
|
-
})
|
|
87
|
-
test('GetRelayTimerInMilliseconds command', () => {
|
|
88
|
-
expect(commandBuilder.build('GetRelayTimerInMilliseconds')).toStrictEqual(
|
|
89
|
-
new BaseCommand('GetRelayTimerInMilliseconds', 0x56),
|
|
90
|
-
)
|
|
91
|
-
})
|
|
92
|
-
test('SetRelayTimerInSeconds command', () => {
|
|
93
|
-
expect(commandBuilder.build('SetRelayTimerInSeconds', { state: 0, time: 3 })).toStrictEqual(
|
|
94
|
-
new BaseCommand('SetRelayTimerInSeconds', 0x57, '00', '0003'),
|
|
95
|
-
)
|
|
96
|
-
})
|
|
97
|
-
test('GetRelayTimerInSeconds command', () => {
|
|
98
|
-
expect(commandBuilder.build('GetRelayTimerInSeconds')).toStrictEqual(new BaseCommand('GetRelayTimerInSeconds', 0x58))
|
|
99
|
-
})
|
|
100
|
-
test('GetRelayStateChangeReason command', () => {
|
|
101
|
-
expect(commandBuilder.build('GetRelayStateChangeReason')).toStrictEqual(
|
|
102
|
-
new BaseCommand('GetRelayStateChangeReason', 0x54),
|
|
103
|
-
)
|
|
104
|
-
})
|
|
105
|
-
})
|
|
106
|
-
describe('16 ADS commands payload encoder', () => {
|
|
107
|
-
const commandBuilder = new CommandBuilder('relay_16_dry')
|
|
108
|
-
|
|
109
|
-
test('SetRelayState command', () => {
|
|
110
|
-
expect(commandBuilder.build('SetRelayState', { state: true })).toStrictEqual(
|
|
111
|
-
new BaseCommand('SetRelayState', 0xc1, '01'),
|
|
112
|
-
)
|
|
113
|
-
})
|
|
114
|
-
test('SetRelayTimerInMilliseconds command', () => {
|
|
115
|
-
expect(commandBuilder.build('SetRelayTimerInMilliseconds', { state: 0, time: 500 })).toStrictEqual(
|
|
116
|
-
new BaseCommand('SetRelayTimerInMilliseconds', 0x55, '00', '01F4'),
|
|
117
|
-
)
|
|
118
|
-
})
|
|
119
|
-
test('GetRelayTimerInMilliseconds command', () => {
|
|
120
|
-
expect(commandBuilder.build('GetRelayTimerInMilliseconds')).toStrictEqual(
|
|
121
|
-
new BaseCommand('GetRelayTimerInMilliseconds', 0x56),
|
|
122
|
-
)
|
|
123
|
-
})
|
|
124
|
-
test('SetRelayTimerInSeconds command', () => {
|
|
125
|
-
expect(commandBuilder.build('SetRelayTimerInSeconds', { state: 0, time: 3 })).toStrictEqual(
|
|
126
|
-
new BaseCommand('SetRelayTimerInSeconds', 0x57, '00', '0003'),
|
|
127
|
-
)
|
|
128
|
-
})
|
|
129
|
-
test('GetRelayTimerInSeconds command', () => {
|
|
130
|
-
expect(commandBuilder.build('GetRelayTimerInSeconds')).toStrictEqual(new BaseCommand('GetRelayTimerInSeconds', 0x58))
|
|
131
|
-
})
|
|
132
|
-
test('GetRelayStateChangeReason command', () => {
|
|
133
|
-
expect(commandBuilder.build('GetRelayStateChangeReason')).toStrictEqual(
|
|
134
|
-
new BaseCommand('GetRelayStateChangeReason', 0x54),
|
|
135
|
-
)
|
|
136
|
-
})
|
|
137
|
-
})
|
|
138
|
-
describe('CO2Display Commands payload encoder', () => {
|
|
139
|
-
const commandBuilder = new CommandBuilder('co2_display')
|
|
140
|
-
|
|
141
|
-
test('Set CO2 Measurement Blind Time', () => {
|
|
142
|
-
expect(commandBuilder.build('SetCo2MeasurementBlindTime', { time: 10 })).toStrictEqual(
|
|
143
|
-
new BaseCommand('SetCo2MeasurementBlindTime', 0x81, '0A'),
|
|
144
|
-
)
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
test('Throw error on invalid Set CO2 Measurement Blind Time params', () => {
|
|
148
|
-
expect(() => commandBuilder.build('SetCo2MeasurementBlindTime', { time: -1 })).toThrow(CustomError)
|
|
149
|
-
})
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
describe('CO2DisplayLite Commands payload encoder', () => {
|
|
153
|
-
const commandBuilder = new CommandBuilder('co2_display_lite')
|
|
154
|
-
|
|
155
|
-
test('Set Uplink Sending On Button Press', () => {
|
|
156
|
-
expect(commandBuilder.build('SetUplinkSendingOnButtonPress', { value: 1 })).toStrictEqual(
|
|
157
|
-
new BaseCommand('SetUplinkSendingOnButtonPress', 0x2e, '01'),
|
|
158
|
-
)
|
|
159
|
-
})
|
|
160
|
-
|
|
161
|
-
test('Restart Device', () => {
|
|
162
|
-
expect(commandBuilder.build('RestartDevice')).toStrictEqual(new BaseCommand('RestartDevice', 0xa5))
|
|
163
|
-
})
|
|
164
|
-
|
|
165
|
-
test('Throw error on invalid Set Uplink Sending On Button Press params', () => {
|
|
166
|
-
expect(() => commandBuilder.build('SetUplinkSendingOnButtonPress', { time: -1 })).toThrow(CustomError)
|
|
167
|
-
})
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
describe('CO2Sensor Commands payload encoder', () => {
|
|
171
|
-
const commandBuilder = new CommandBuilder('co2_sensor')
|
|
172
|
-
|
|
173
|
-
test('Set CO2 Boundary Levels (valid range)', () => {
|
|
174
|
-
expect(commandBuilder.build('SetCo2BoundaryLevels', { good_medium: 200, medium_bad: 250 })).toStrictEqual(
|
|
175
|
-
new BaseCommand('SetCo2BoundaryLevels', 0x1e, '00C8', '00FA'),
|
|
176
|
-
)
|
|
177
|
-
})
|
|
178
|
-
|
|
179
|
-
test('Throw error on invalid CO2 Boundary Levels (out of range)', () => {
|
|
180
|
-
expect(() => commandBuilder.build('SetCo2BoundaryLevels', { good_medium: 65536, medium_bad: 66536 })).toThrow(
|
|
181
|
-
CustomError,
|
|
182
|
-
)
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
test('Get CO2 Boundary Levels', () => {
|
|
186
|
-
expect(commandBuilder.build('GetCo2BoundaryLevels')).toStrictEqual(new BaseCommand('GetCo2BoundaryLevels', 0x1f))
|
|
187
|
-
})
|
|
188
|
-
|
|
189
|
-
test('Set CO2 Auto Zero Value (valid range)', () => {
|
|
190
|
-
expect(commandBuilder.build('SetCo2AutoZeroValue', { ppm: 150 })).toStrictEqual(
|
|
191
|
-
new BaseCommand('SetCo2AutoZeroValue', 0x20, '0096'),
|
|
192
|
-
)
|
|
193
|
-
})
|
|
194
|
-
|
|
195
|
-
test('Throw error on invalid CO2 Auto Zero Value (out of range)', () => {
|
|
196
|
-
expect(() => commandBuilder.build('SetCo2AutoZeroValue', { ppm: 65539 })).toThrow(CustomError)
|
|
197
|
-
})
|
|
198
|
-
|
|
199
|
-
test('Get CO2 Auto Zero Value', () => {
|
|
200
|
-
expect(commandBuilder.build('GetCo2AutoZeroValue')).toStrictEqual(new BaseCommand('GetCo2AutoZeroValue', 0x21))
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
test('Set Notify Period', () => {
|
|
204
|
-
expect(commandBuilder.build('SetNotifyPeriod', { good_zone: 60, medium_zone: 120, bad_zone: 180 })).toStrictEqual(
|
|
205
|
-
new BaseCommand('SetNotifyPeriod', 0x22, '3C', '78', 'B4'),
|
|
206
|
-
)
|
|
207
|
-
})
|
|
208
|
-
|
|
209
|
-
test('Get Notify Period', () => {
|
|
210
|
-
expect(commandBuilder.build('GetNotifyPeriod')).toStrictEqual(new BaseCommand('GetNotifyPeriod', 0x23))
|
|
211
|
-
})
|
|
212
|
-
|
|
213
|
-
test('Set CO2 Measurement Period', () => {
|
|
214
|
-
expect(
|
|
215
|
-
commandBuilder.build('SetCo2MeasurementPeriod', { good_zone: 5, medium_zone: 10, bad_zone: 15 }),
|
|
216
|
-
).toStrictEqual(new BaseCommand('SetCo2MeasurementPeriod', 0x24, '05', '0A', '0F'))
|
|
217
|
-
})
|
|
218
|
-
|
|
219
|
-
test('Get CO2 Measurement Period', () => {
|
|
220
|
-
expect(commandBuilder.build('GetCo2MeasurementPeriod')).toStrictEqual(
|
|
221
|
-
new BaseCommand('GetCo2MeasurementPeriod', 0x25),
|
|
222
|
-
)
|
|
223
|
-
})
|
|
224
|
-
|
|
225
|
-
test('Set Buzzer Notification', () => {
|
|
226
|
-
expect(
|
|
227
|
-
commandBuilder.build('SetBuzzerNotification', {
|
|
228
|
-
duration_good_beeping: 10,
|
|
229
|
-
duration_good_loud: 20,
|
|
230
|
-
duration_good_silent: 30,
|
|
231
|
-
duration_medium_beeping: 40,
|
|
232
|
-
duration_medium_loud: 50,
|
|
233
|
-
duration_medium_silent: 60,
|
|
234
|
-
duration_bad_beeping: 70,
|
|
235
|
-
duration_bad_loud: 80,
|
|
236
|
-
duration_bad_silent: 90,
|
|
237
|
-
}),
|
|
238
|
-
).toStrictEqual(new BaseCommand('SetBuzzerNotification', 0x26, '0A', '02', '03', '28', '05', '06', '46', '08', '09'))
|
|
239
|
-
})
|
|
240
|
-
|
|
241
|
-
test('Get Buzzer Notification', () => {
|
|
242
|
-
expect(commandBuilder.build('GetBuzzerNotification')).toStrictEqual(new BaseCommand('GetBuzzerNotification', 0x27))
|
|
243
|
-
})
|
|
244
|
-
|
|
245
|
-
test('Set CO2 LED', () => {
|
|
246
|
-
expect(
|
|
247
|
-
commandBuilder.build('SetCo2Led', {
|
|
248
|
-
red_good: 10,
|
|
249
|
-
green_good: 20,
|
|
250
|
-
blue_good: 30,
|
|
251
|
-
duration_good: 40,
|
|
252
|
-
red_medium: 50,
|
|
253
|
-
green_medium: 60,
|
|
254
|
-
blue_medium: 70,
|
|
255
|
-
duration_medium: 80,
|
|
256
|
-
red_bad: 90,
|
|
257
|
-
green_bad: 100,
|
|
258
|
-
blue_bad: 110,
|
|
259
|
-
duration_bad: 120,
|
|
260
|
-
}),
|
|
261
|
-
).toStrictEqual(
|
|
262
|
-
new BaseCommand('SetCo2Led', 0x28, '0A', '14', '1E', '0004', '32', '3C', '46', '0008', '5A', '64', '6E', '000C'),
|
|
263
|
-
)
|
|
264
|
-
})
|
|
265
|
-
|
|
266
|
-
test('Get CO2 LED', () => {
|
|
267
|
-
expect(commandBuilder.build('GetCo2Led')).toStrictEqual(new BaseCommand('GetCo2Led', 0x29))
|
|
268
|
-
})
|
|
269
|
-
|
|
270
|
-
test('Set CO2 Auto Zero Period', () => {
|
|
271
|
-
expect(commandBuilder.build('SetCo2AutoZeroPeriod', { hours: 24 })).toStrictEqual(
|
|
272
|
-
new BaseCommand('SetCo2AutoZeroPeriod', 0x2a, '18'),
|
|
273
|
-
)
|
|
274
|
-
})
|
|
275
|
-
|
|
276
|
-
test('Get CO2 Auto Zero Period', () => {
|
|
277
|
-
expect(commandBuilder.build('GetCo2AutoZeroPeriod')).toStrictEqual(new BaseCommand('GetCo2AutoZeroPeriod', 0x2b))
|
|
278
|
-
})
|
|
279
|
-
})
|
|
280
|
-
|
|
281
|
-
describe('FanCoilThermostat Commands payload encoder', () => {
|
|
282
|
-
const commandBuilder = new CommandBuilder('fan_coil_thermostat')
|
|
283
|
-
|
|
284
|
-
test('Set Target Temperature Step', () => {
|
|
285
|
-
expect(commandBuilder.build('SetTargetTemperatureStep', { value: 2.2 })).toStrictEqual(
|
|
286
|
-
new BaseCommand('SetTargetTemperatureStep', 0x03, '16'),
|
|
287
|
-
)
|
|
288
|
-
})
|
|
289
|
-
|
|
290
|
-
test('Throw error on invalid Target Temperature Step', () => {
|
|
291
|
-
expect(() => commandBuilder.build('SetTargetTemperatureStep', { value: -5 })).toThrow(CustomError)
|
|
292
|
-
})
|
|
293
|
-
|
|
294
|
-
test('Set Keys Lock', () => {
|
|
295
|
-
expect(commandBuilder.build('SetKeysLock', { value: 1 })).toStrictEqual(new BaseCommand('SetKeysLock', 0x07, '01'))
|
|
296
|
-
})
|
|
297
|
-
|
|
298
|
-
test('Set Target Temperature', () => {
|
|
299
|
-
expect(commandBuilder.build('SetTargetTemperature', { targetTemperature: 25 })).toStrictEqual(
|
|
300
|
-
new BaseCommand('SetTargetTemperature', 0x2e, '00FA'),
|
|
301
|
-
)
|
|
302
|
-
})
|
|
303
|
-
|
|
304
|
-
test('Set FCT Operational Mode', () => {
|
|
305
|
-
expect(commandBuilder.build('SetFctOperationalMode', { value: 2 })).toStrictEqual(
|
|
306
|
-
new BaseCommand('SetFctOperationalMode', 0x52, '02'),
|
|
307
|
-
)
|
|
308
|
-
})
|
|
309
|
-
|
|
310
|
-
test('Set Valve Open Close Time', () => {
|
|
311
|
-
expect(commandBuilder.build('SetValveOpenCloseTime', { value: 5 })).toStrictEqual(
|
|
312
|
-
new BaseCommand('SetValveOpenCloseTime', 0x31, '05'),
|
|
313
|
-
)
|
|
314
|
-
})
|
|
315
|
-
|
|
316
|
-
test('Set External Automatic Temperature Control', () => {
|
|
317
|
-
expect(commandBuilder.build('SetExtAutomaticTemperatureControl', { value: 1 })).toStrictEqual(
|
|
318
|
-
new BaseCommand('SetExtAutomaticTemperatureControl', 0x35, '01'),
|
|
319
|
-
)
|
|
320
|
-
})
|
|
321
|
-
|
|
322
|
-
test('Set Fan Speed', () => {
|
|
323
|
-
expect(commandBuilder.build('SetFanSpeed', { value: 2 })).toStrictEqual(new BaseCommand('SetFanSpeed', 0x44, '02'))
|
|
324
|
-
})
|
|
325
|
-
|
|
326
|
-
test('Set Fan Speed Limit', () => {
|
|
327
|
-
expect(commandBuilder.build('SetFanSpeedLimit', { value: 3 })).toStrictEqual(
|
|
328
|
-
new BaseCommand('SetFanSpeedLimit', 0x46, '03'),
|
|
329
|
-
)
|
|
330
|
-
})
|
|
331
|
-
|
|
332
|
-
test('Set ECM Voltage Range', () => {
|
|
333
|
-
expect(commandBuilder.build('SetEcmVoltageRange', { min: 2, max: 5 })).toStrictEqual(
|
|
334
|
-
new BaseCommand('SetEcmVoltageRange', 0x48, '14', '32'),
|
|
335
|
-
)
|
|
336
|
-
})
|
|
337
|
-
|
|
338
|
-
test('Set ECM Start Up Time', () => {
|
|
339
|
-
expect(commandBuilder.build('SetEcmStartUpTime', { value: 10 })).toStrictEqual(
|
|
340
|
-
new BaseCommand('SetEcmStartUpTime', 0x4a, '0A'),
|
|
341
|
-
)
|
|
342
|
-
})
|
|
343
|
-
|
|
344
|
-
test('Set ECM Relay', () => {
|
|
345
|
-
expect(commandBuilder.build('SetEcmRelay', { value: 1 })).toStrictEqual(new BaseCommand('SetEcmRelay', 0x4c, '01'))
|
|
346
|
-
})
|
|
347
|
-
|
|
348
|
-
test('Set Frost Protection', () => {
|
|
349
|
-
expect(commandBuilder.build('SetFrostProtection', { value: 1 })).toStrictEqual(
|
|
350
|
-
new BaseCommand('SetFrostProtection', 0x4e, '01'),
|
|
351
|
-
)
|
|
352
|
-
})
|
|
353
|
-
|
|
354
|
-
test('Set Frost Protection Settings', () => {
|
|
355
|
-
expect(commandBuilder.build('SetFrostProtectionSettings', { threshold: 5, setpoint: 10 })).toStrictEqual(
|
|
356
|
-
new BaseCommand('SetFrostProtectionSettings', 0x50, '05', '0A'),
|
|
357
|
-
)
|
|
358
|
-
})
|
|
359
|
-
|
|
360
|
-
test('Set Allowed Operational Modes', () => {
|
|
361
|
-
expect(commandBuilder.build('SetAllowedOperationalModes', { value: 2 })).toStrictEqual(
|
|
362
|
-
new BaseCommand('SetAllowedOperationalModes', 0x54, '02'),
|
|
363
|
-
)
|
|
364
|
-
})
|
|
365
|
-
|
|
366
|
-
test('Set Cooling Setpoint Not Occupied', () => {
|
|
367
|
-
expect(commandBuilder.build('SetCoolingSetpointNotOccupied', { value: 23 })).toStrictEqual(
|
|
368
|
-
new BaseCommand('SetCoolingSetpointNotOccupied', 0x56, '17'),
|
|
369
|
-
)
|
|
370
|
-
})
|
|
371
|
-
|
|
372
|
-
test('Set Heating Setpoint Not Occupied', () => {
|
|
373
|
-
expect(commandBuilder.build('SetHeatingSetpointNotOccupied', { value: 20 })).toStrictEqual(
|
|
374
|
-
new BaseCommand('SetHeatingSetpointNotOccupied', 0x58, '14'),
|
|
375
|
-
)
|
|
376
|
-
})
|
|
377
|
-
|
|
378
|
-
test('Set Temperature Sensor Compensation', () => {
|
|
379
|
-
expect(commandBuilder.build('SetTempSensorCompensation', { compensation: 1, temperature: 2.5 })).toStrictEqual(
|
|
380
|
-
new BaseCommand('SetTempSensorCompensation', 0x5a, '01', '19'),
|
|
381
|
-
)
|
|
382
|
-
})
|
|
383
|
-
|
|
384
|
-
test('Set Fan Speed Not Occupied', () => {
|
|
385
|
-
expect(commandBuilder.build('SetFanSpeedNotOccupied', { value: 2 })).toStrictEqual(
|
|
386
|
-
new BaseCommand('SetFanSpeedNotOccupied', 0x5c, '02'),
|
|
387
|
-
)
|
|
388
|
-
})
|
|
389
|
-
|
|
390
|
-
test('Set Automatic Changeover', () => {
|
|
391
|
-
expect(commandBuilder.build('SetAutomaticChangeover', { value: 1 })).toStrictEqual(
|
|
392
|
-
new BaseCommand('SetAutomaticChangeover', 0x5e, '01'),
|
|
393
|
-
)
|
|
394
|
-
})
|
|
395
|
-
|
|
396
|
-
test('Set Wiring Diagram', () => {
|
|
397
|
-
expect(commandBuilder.build('SetWiringDiagram', { value: 1 })).toStrictEqual(
|
|
398
|
-
new BaseCommand('SetWiringDiagram', 0x60, '01'),
|
|
399
|
-
)
|
|
400
|
-
})
|
|
401
|
-
|
|
402
|
-
test('Set Occupancy Function', () => {
|
|
403
|
-
expect(commandBuilder.build('SetOccFunction', { value: 1 })).toStrictEqual(
|
|
404
|
-
new BaseCommand('SetOccFunction', 0x62, '01'),
|
|
405
|
-
)
|
|
406
|
-
})
|
|
407
|
-
|
|
408
|
-
test('Set Automatic Changeover Threshold', () => {
|
|
409
|
-
expect(
|
|
410
|
-
commandBuilder.build('SetAutomaticChangeoverThreshold', { coolingThreshold: 16, heatingThreshold: 43 }),
|
|
411
|
-
).toStrictEqual(new BaseCommand('SetAutomaticChangeoverThreshold', 0x64, '10', '2B'))
|
|
412
|
-
})
|
|
413
|
-
|
|
414
|
-
test('Set Device Status', () => {
|
|
415
|
-
expect(commandBuilder.build('SetDeviceStatus', { value: 1 })).toStrictEqual(
|
|
416
|
-
new BaseCommand('SetDeviceStatus', 0x66, '01'),
|
|
417
|
-
)
|
|
418
|
-
})
|
|
419
|
-
|
|
420
|
-
test('Set Return of Power Operation', () => {
|
|
421
|
-
expect(commandBuilder.build('SetReturnOfPowerOperation', { value: 2 })).toStrictEqual(
|
|
422
|
-
new BaseCommand('SetReturnOfPowerOperation', 0x68, '02'),
|
|
423
|
-
)
|
|
424
|
-
})
|
|
425
|
-
|
|
426
|
-
test('Set Delta Temperature 1', () => {
|
|
427
|
-
expect(commandBuilder.build('SetDeltaTemperature1', { value: 3 })).toStrictEqual(
|
|
428
|
-
new BaseCommand('SetDeltaTemperature1', 0x6a, '1E'),
|
|
429
|
-
)
|
|
430
|
-
})
|
|
431
|
-
|
|
432
|
-
test('Set Delta Temperature 2 and 3', () => {
|
|
433
|
-
expect(
|
|
434
|
-
commandBuilder.build('SetDeltaTemperature2and3', { deltaTemperature2: 4, deltaTemperature3: 5 }),
|
|
435
|
-
).toStrictEqual(new BaseCommand('SetDeltaTemperature2and3', 0x6c, '28', '32'))
|
|
436
|
-
})
|
|
437
|
-
|
|
438
|
-
test('Set Heating Cooling Target Temp Ranges', () => {
|
|
439
|
-
expect(
|
|
440
|
-
commandBuilder.build('SetHeatingCoolingTargetTempRanges', {
|
|
441
|
-
heatingTempMin: 16,
|
|
442
|
-
heatingTempMax: 24,
|
|
443
|
-
coolingTempMin: 20,
|
|
444
|
-
coolingTempMax: 29,
|
|
445
|
-
}),
|
|
446
|
-
).toStrictEqual(new BaseCommand('SetHeatingCoolingTargetTempRanges', 0x16, '10', '18', '14', '1D'))
|
|
447
|
-
})
|
|
448
|
-
|
|
449
|
-
test('Set Heating Cooling Target Temp Ranges Unoccupied', () => {
|
|
450
|
-
expect(
|
|
451
|
-
commandBuilder.build('SetHeatingCoolingTargetTempRangesUnoccupied', {
|
|
452
|
-
heatingTempMin: 16,
|
|
453
|
-
heatingTempMax: 24,
|
|
454
|
-
coolingTempMin: 20,
|
|
455
|
-
coolingTempMax: 29,
|
|
456
|
-
}),
|
|
457
|
-
).toStrictEqual(new BaseCommand('SetHeatingCoolingTargetTempRangesUnoccupied', 0x76, '10', '18', '14', '1D'))
|
|
458
|
-
})
|
|
459
|
-
})
|
|
460
|
-
|
|
461
|
-
describe('Vicki Commands payload encoder', () => {
|
|
462
|
-
const commandBuilder = new CommandBuilder('vicki')
|
|
463
|
-
|
|
464
|
-
test('Recalibrate Motor', () => {
|
|
465
|
-
expect(commandBuilder.build('RecalibrateMotor')).toStrictEqual(new BaseCommand('RecalibrateMotor', 0x03))
|
|
466
|
-
})
|
|
467
|
-
|
|
468
|
-
test('Set Open Window Detection Parameters', () => {
|
|
469
|
-
expect(
|
|
470
|
-
commandBuilder.build('SetOpenWindow', {
|
|
471
|
-
enabled: true,
|
|
472
|
-
delta: 3,
|
|
473
|
-
closeTime: 20,
|
|
474
|
-
motorPosition: 450,
|
|
475
|
-
}),
|
|
476
|
-
).toStrictEqual(new BaseCommand('SetOpenWindow', 0x06, '01', '04', 'C2', '13', '3'))
|
|
477
|
-
|
|
478
|
-
expect(
|
|
479
|
-
commandBuilder.build('SetOpenWindow', {
|
|
480
|
-
enabled: false,
|
|
481
|
-
delta: 3,
|
|
482
|
-
closeTime: 20,
|
|
483
|
-
motorPosition: 450,
|
|
484
|
-
}),
|
|
485
|
-
).toStrictEqual(new BaseCommand('SetOpenWindow', 0x06, '00', '04', 'C2', '13', '3'))
|
|
486
|
-
})
|
|
487
|
-
|
|
488
|
-
test('Set Internal Algo Params', () => {
|
|
489
|
-
expect(
|
|
490
|
-
commandBuilder.build('SetInternalAlgoParams', {
|
|
491
|
-
period: 5,
|
|
492
|
-
pFirstLast: 10,
|
|
493
|
-
pNext: 15,
|
|
494
|
-
}),
|
|
495
|
-
).toStrictEqual(new BaseCommand('SetInternalAlgoParams', 0x0c, '05', '0A', '0F'))
|
|
496
|
-
})
|
|
497
|
-
|
|
498
|
-
test('Set Operational Mode', () => {
|
|
499
|
-
expect(commandBuilder.build('SetOperationalMode', { mode: '01' })).toStrictEqual(
|
|
500
|
-
new BaseCommand('SetOperationalMode', 0x0d, '01'),
|
|
501
|
-
)
|
|
502
|
-
})
|
|
503
|
-
|
|
504
|
-
test('Set Target Temperature (Integer)', () => {
|
|
505
|
-
expect(commandBuilder.build('SetTargetTemperature', { targetTemperature: 22 })).toStrictEqual(
|
|
506
|
-
new BaseCommand('SetTargetTemperature', 0x0e, '16'),
|
|
507
|
-
)
|
|
508
|
-
})
|
|
509
|
-
|
|
510
|
-
test('Set Target Temperature (Float)', () => {
|
|
511
|
-
expect(commandBuilder.build('SetTargetTemperature', { targetTemperature: 22.5 })).toStrictEqual(
|
|
512
|
-
new BaseCommand('SetTargetTemperature', 0x51, '00E1'),
|
|
513
|
-
)
|
|
514
|
-
})
|
|
515
|
-
|
|
516
|
-
test('Set External Temperature', () => {
|
|
517
|
-
expect(commandBuilder.build('SetExternalTemperature', { temp: 18 })).toStrictEqual(
|
|
518
|
-
new BaseCommand('SetExternalTemperature', 0x0f, '12'),
|
|
519
|
-
)
|
|
520
|
-
})
|
|
521
|
-
|
|
522
|
-
test('Set Internal Algo Tdiff Params', () => {
|
|
523
|
-
expect(
|
|
524
|
-
commandBuilder.build('SetInternalAlgoTdiffParams', {
|
|
525
|
-
cold: 8,
|
|
526
|
-
warm: 12,
|
|
527
|
-
}),
|
|
528
|
-
).toStrictEqual(new BaseCommand('SetInternalAlgoTdiffParams', 0x1a, '08', '0C'))
|
|
529
|
-
})
|
|
530
|
-
|
|
531
|
-
test('Set Primary Operational Mode', () => {
|
|
532
|
-
expect(commandBuilder.build('SetPrimaryOperationalMode', { mode: '01' })).toStrictEqual(
|
|
533
|
-
new BaseCommand('SetPrimaryOperationalMode', 0x1e, '01'),
|
|
534
|
-
)
|
|
535
|
-
})
|
|
536
|
-
|
|
537
|
-
test('Set Battery Ranges Boundaries', () => {
|
|
538
|
-
expect(
|
|
539
|
-
commandBuilder.build('SetBatteryRangesBoundaries', {
|
|
540
|
-
Boundary1: 2000,
|
|
541
|
-
Boundary2: 3000,
|
|
542
|
-
Boundary3: 4000,
|
|
543
|
-
}),
|
|
544
|
-
).toStrictEqual(new BaseCommand('SetBatteryRangesBoundaries', 0x20, '07D0', '0BB8', '0FA0'))
|
|
545
|
-
})
|
|
546
|
-
|
|
547
|
-
test('Set Ovac', () => {
|
|
548
|
-
expect(commandBuilder.build('SetOvac', { ovac: 12 })).toStrictEqual(new BaseCommand('SetOvac', 0x26, '0C'))
|
|
549
|
-
})
|
|
550
|
-
|
|
551
|
-
test('Set Proportional Algorithm Parameters', () => {
|
|
552
|
-
expect(
|
|
553
|
-
commandBuilder.build('SetProportionalAlgorithmParameters', {
|
|
554
|
-
coefficient: 5,
|
|
555
|
-
period: 15,
|
|
556
|
-
}),
|
|
557
|
-
).toStrictEqual(new BaseCommand('SetProportionalAlgorithmParameters', 0x2a, '05', '0F'))
|
|
558
|
-
})
|
|
559
|
-
|
|
560
|
-
test('Set Valve Openness In Percentage', () => {
|
|
561
|
-
expect(commandBuilder.build('SetValveOpennessInPercentage', { value: 75 })).toStrictEqual(
|
|
562
|
-
new BaseCommand('SetValveOpennessInPercentage', 0x4e, '4B'),
|
|
563
|
-
)
|
|
564
|
-
})
|
|
565
|
-
|
|
566
|
-
test('Set Temperature Offset', () => {
|
|
567
|
-
expect(commandBuilder.build('SetTemperatureOffset', { value: -1 })).toStrictEqual(
|
|
568
|
-
new BaseCommand('SetTemperatureOffset', 0x53, '16'),
|
|
569
|
-
)
|
|
570
|
-
|
|
571
|
-
expect(commandBuilder.build('SetTemperatureOffset', { value: 0 })).toStrictEqual(
|
|
572
|
-
new BaseCommand('SetTemperatureOffset', 0x53, '1C'),
|
|
573
|
-
)
|
|
574
|
-
|
|
575
|
-
expect(commandBuilder.build('SetTemperatureOffset', { value: 3 })).toStrictEqual(
|
|
576
|
-
new BaseCommand('SetTemperatureOffset', 0x53, '2D'),
|
|
577
|
-
)
|
|
578
|
-
})
|
|
579
|
-
|
|
580
|
-
test('Set Time Request By MAC Command', () => {
|
|
581
|
-
expect(commandBuilder.build('SetTimeRequestByMACcommand', { enabled: true })).toStrictEqual(
|
|
582
|
-
new BaseCommand('SetTimeRequestByMACcommand', 0x6d, '01'),
|
|
583
|
-
)
|
|
584
|
-
})
|
|
585
|
-
|
|
586
|
-
test('Set Heating Schedule', () => {
|
|
587
|
-
// Example 1: Set schedule from 1st November to 1st April
|
|
588
|
-
expect(
|
|
589
|
-
commandBuilder.build('SetHeatingSchedule', {
|
|
590
|
-
startMonth: 10, // November (0-based indexing)
|
|
591
|
-
startDay: 1,
|
|
592
|
-
endMonth: 3, // April (0-based indexing)
|
|
593
|
-
endDay: 1,
|
|
594
|
-
}),
|
|
595
|
-
).toStrictEqual(new BaseCommand('SetHeatingSchedule', 0x5b, '0A', '01', '03', '01'))
|
|
596
|
-
})
|
|
597
|
-
|
|
598
|
-
test('Set Device Time', () => {
|
|
599
|
-
// Example from documentation: June 29, 2025 06:00:00 GMT
|
|
600
|
-
// UNIX timestamp: 1751176800
|
|
601
|
-
expect(
|
|
602
|
-
commandBuilder.build('SetDeviceTime', {
|
|
603
|
-
timestamp: 1751176800,
|
|
604
|
-
}),
|
|
605
|
-
).toStrictEqual(new BaseCommand('SetDeviceTime', 0x5d, '68', '60', 'D6', '60'))
|
|
606
|
-
})
|
|
607
|
-
|
|
608
|
-
test('Set Device Time Zone', () => {
|
|
609
|
-
// Test positive offset: +2 hours
|
|
610
|
-
expect(
|
|
611
|
-
commandBuilder.build('SetDeviceTimeZone', {
|
|
612
|
-
offsetHours: 2,
|
|
613
|
-
}),
|
|
614
|
-
).toStrictEqual(new BaseCommand('SetDeviceTimeZone', 0x5f, '02'))
|
|
615
|
-
|
|
616
|
-
// Test negative offset: -3 hours (example from documentation)
|
|
617
|
-
expect(
|
|
618
|
-
commandBuilder.build('SetDeviceTimeZone', {
|
|
619
|
-
offsetHours: -3,
|
|
620
|
-
}),
|
|
621
|
-
).toStrictEqual(new BaseCommand('SetDeviceTimeZone', 0x5f, 'FD'))
|
|
622
|
-
})
|
|
623
|
-
|
|
624
|
-
test('Set Automatic Setpoint Restore', () => {
|
|
625
|
-
// Test with 60 minutes (example from documentation - 6*10=60 minutes)
|
|
626
|
-
expect(
|
|
627
|
-
commandBuilder.build('SetAutomaticSetpointRestore', {
|
|
628
|
-
time: 60, // minutes
|
|
629
|
-
}),
|
|
630
|
-
).toStrictEqual(new BaseCommand('SetAutomaticSetpointRestore', 0x61, '06'))
|
|
631
|
-
})
|
|
632
|
-
|
|
633
|
-
test('Set Offline Target Temperature', () => {
|
|
634
|
-
// Test with normal temperature - 21.5°C (example from documentation)
|
|
635
|
-
expect(
|
|
636
|
-
commandBuilder.build('SetOfflineTargetTemperature', {
|
|
637
|
-
targetTemperature: 21.5,
|
|
638
|
-
}),
|
|
639
|
-
).toStrictEqual(new BaseCommand('SetOfflineTargetTemperature', 0x65, '00D7'))
|
|
640
|
-
})
|
|
641
|
-
|
|
642
|
-
test('Set Internal Algorithm Temporary State', () => {
|
|
643
|
-
// Test temporary disable internal algorithm (example from documentation)
|
|
644
|
-
expect(
|
|
645
|
-
commandBuilder.build('SetInternalAlgoTemporaryState', {
|
|
646
|
-
enabled: false, // Disable temporarily
|
|
647
|
-
}),
|
|
648
|
-
).toStrictEqual(new BaseCommand('SetInternalAlgoTemporaryState', 0x67, '01'))
|
|
649
|
-
})
|
|
650
|
-
|
|
651
|
-
test('Set Temperature Levels', () => {
|
|
652
|
-
// Test with the example values from documentation
|
|
653
|
-
expect(
|
|
654
|
-
commandBuilder.build('SetTemperatureLevels', {
|
|
655
|
-
scaleLevel0: 7.0, // 0x0046 = 70
|
|
656
|
-
scaleLevel1: 18.9, // 0x00BD = 189
|
|
657
|
-
scaleLevel2: 20.2, // 0x00CA = 202
|
|
658
|
-
scaleLevel3: 22.5, // 0x00E1 = 225
|
|
659
|
-
scaleLevel4: 25.0, // 0x00FA = 250
|
|
660
|
-
scaleLevel5: 30.0, // 0x012C = 300
|
|
661
|
-
}),
|
|
662
|
-
).toStrictEqual(
|
|
663
|
-
new BaseCommand(
|
|
664
|
-
'SetTemperatureLevels',
|
|
665
|
-
0x69,
|
|
666
|
-
'0046', // Level 0: 7.0°C
|
|
667
|
-
'00BD', // Level 1: 18.9°C
|
|
668
|
-
'00CA', // Level 2: 20.2°C
|
|
669
|
-
'00E1', // Level 3: 22.5°C
|
|
670
|
-
'00FA', // Level 4: 25.0°C
|
|
671
|
-
'012C', // Level 5: 30.0°C
|
|
672
|
-
),
|
|
673
|
-
)
|
|
674
|
-
})
|
|
675
|
-
|
|
676
|
-
test('Set LED Indication Duration', () => {
|
|
677
|
-
// Example from documentation: 0x64 - duration value 6 (3 seconds)
|
|
678
|
-
expect(
|
|
679
|
-
commandBuilder.build('SetLedIndicationDuration', {
|
|
680
|
-
duration: 3, // seconds
|
|
681
|
-
}),
|
|
682
|
-
).toStrictEqual(new BaseCommand('SetLedIndicationDuration', 0x63, '06'))
|
|
683
|
-
})
|
|
684
|
-
})
|
|
685
|
-
|
|
686
|
-
describe('WirelessThermostat Commands payload encoder', () => {
|
|
687
|
-
const commandBuilder = new CommandBuilder('wireless_thermostat')
|
|
688
|
-
|
|
689
|
-
test('Set Target Temperature', () => {
|
|
690
|
-
expect(commandBuilder.build('SetTargetTemperature', { targetTemperature: 22 })).toStrictEqual(
|
|
691
|
-
new BaseCommand('SetTargetTemperature', 0x2e, '16'),
|
|
692
|
-
)
|
|
693
|
-
})
|
|
694
|
-
test('Set Target Temperature Float', () => {
|
|
695
|
-
expect(commandBuilder.build('SetTargetTemperature', { targetTemperature: 22.5 })).toStrictEqual(
|
|
696
|
-
new BaseCommand('SetTargetTemperature', 0x50, '00E1'),
|
|
697
|
-
)
|
|
698
|
-
})
|
|
699
|
-
|
|
700
|
-
test('Set Heating Status', () => {
|
|
701
|
-
expect(commandBuilder.build('SetHeatingStatus', { status: 1 })).toStrictEqual(
|
|
702
|
-
new BaseCommand('SetHeatingStatus', 0x31, '01'),
|
|
703
|
-
)
|
|
704
|
-
})
|
|
705
|
-
|
|
706
|
-
test('Set Display Refresh Period', () => {
|
|
707
|
-
expect(commandBuilder.build('SetDisplayRefreshPeriod', { period: 10 })).toStrictEqual(
|
|
708
|
-
new BaseCommand('SetDisplayRefreshPeriod', 0x33, '0A'),
|
|
709
|
-
)
|
|
710
|
-
})
|
|
711
|
-
|
|
712
|
-
test('Set Target Send Delay', () => {
|
|
713
|
-
expect(commandBuilder.build('SetTargetSendDelay', { time: 15 })).toStrictEqual(
|
|
714
|
-
new BaseCommand('SetTargetSendDelay', 0x35, '0F'),
|
|
715
|
-
)
|
|
716
|
-
})
|
|
717
|
-
|
|
718
|
-
test('Set Automatic Heating Status', () => {
|
|
719
|
-
expect(commandBuilder.build('SetAutomaticHeatingStatus', { state: 1 })).toStrictEqual(
|
|
720
|
-
new BaseCommand('SetAutomaticHeatingStatus', 0x37, '01'),
|
|
721
|
-
)
|
|
722
|
-
})
|
|
723
|
-
|
|
724
|
-
test('Set Sensor Mode', () => {
|
|
725
|
-
expect(commandBuilder.build('SetSensorMode', { state: 1 })).toStrictEqual(
|
|
726
|
-
new BaseCommand('SetSensorMode', 0x39, '01'),
|
|
727
|
-
)
|
|
728
|
-
})
|
|
729
|
-
|
|
730
|
-
test('Set Temperature Hysteresis', () => {
|
|
731
|
-
expect(commandBuilder.build('SetTemperatureHysteresis', { hysteresis: 2.5 })).toStrictEqual(
|
|
732
|
-
new BaseCommand('SetTemperatureHysteresis', 0x4e, '19'),
|
|
733
|
-
)
|
|
734
|
-
})
|
|
735
|
-
|
|
736
|
-
test('Set Target Temperature Precisely', () => {
|
|
737
|
-
expect(commandBuilder.build('SetTargetTemperaturePrecisely', { targetTemperature: 22.5 })).toStrictEqual(
|
|
738
|
-
new BaseCommand('SetTargetTemperaturePrecisely', 0x50, '00E1'),
|
|
739
|
-
)
|
|
740
|
-
})
|
|
741
|
-
|
|
742
|
-
test('Set Target Temperature Step', () => {
|
|
743
|
-
expect(commandBuilder.build('SetTargetTemperatureStep', { value: 0.5 })).toStrictEqual(
|
|
744
|
-
new BaseCommand('SetTargetTemperatureStep', 0x52, '05'),
|
|
745
|
-
)
|
|
746
|
-
})
|
|
747
|
-
})
|
|
748
|
-
|
|
749
|
-
describe('TFlood Commands payload encoder', () => {
|
|
750
|
-
const commandBuilder = new CommandBuilder('t_flood')
|
|
751
|
-
|
|
752
|
-
test('Set Flood Alarm Time', () => {
|
|
753
|
-
expect(commandBuilder.build('SetFloodAlarmTime', { time: 15 })).toStrictEqual(
|
|
754
|
-
new BaseCommand('SetFloodAlarmTime', 0x04, 'f'),
|
|
755
|
-
)
|
|
756
|
-
})
|
|
757
|
-
|
|
758
|
-
test('Set Keep Alive', () => {
|
|
759
|
-
expect(commandBuilder.build('SetKeepAlive', { time: 120 })).toStrictEqual(
|
|
760
|
-
new BaseCommand('SetKeepAlive', 0x05, '0078'),
|
|
761
|
-
)
|
|
762
|
-
})
|
|
763
|
-
|
|
764
|
-
test('Set Flood Event Send Time', () => {
|
|
765
|
-
expect(commandBuilder.build('SetFloodEventSendTime', { time: 30 })).toStrictEqual(
|
|
766
|
-
new BaseCommand('SetFloodEventSendTime', 0x08, '1e'),
|
|
767
|
-
)
|
|
768
|
-
})
|
|
769
|
-
|
|
770
|
-
test('Set Flood Event Uplink Type', () => {
|
|
771
|
-
expect(commandBuilder.build('SetFloodEventUplinkType', { type: '01' })).toStrictEqual(
|
|
772
|
-
new BaseCommand('SetFloodEventUplinkType', 0x13, '01'),
|
|
773
|
-
)
|
|
774
|
-
})
|
|
775
|
-
})
|
|
776
|
-
|
|
777
|
-
describe('HT Sensor Commands payload encoder', () => {
|
|
778
|
-
const commandBuilder = new CommandBuilder('ht_sensor')
|
|
779
|
-
|
|
780
|
-
test('Set Temperature Compensation', () => {
|
|
781
|
-
expect(
|
|
782
|
-
commandBuilder.build('SetTemperatureCompensation', { negativeCompensation: true, compensation: 0.3 }),
|
|
783
|
-
).toStrictEqual(new BaseCommand('SetTemperatureCompensation', 0x31, '01', '03'))
|
|
784
|
-
})
|
|
785
|
-
|
|
786
|
-
test('Set Humidity Compensation', () => {
|
|
787
|
-
expect(
|
|
788
|
-
commandBuilder.build('SetHumidityCompensation', { negativeCompensation: true, compensation: 3 }),
|
|
789
|
-
).toStrictEqual(new BaseCommand('SetHumidityCompensation', 0x33, '01', '03'))
|
|
790
|
-
})
|
|
791
|
-
})
|
|
792
|
-
|
|
793
|
-
describe('MC Button Commands payload encoder', () => {
|
|
794
|
-
const commandBuilder = new CommandBuilder('mc_button')
|
|
795
|
-
|
|
796
|
-
test('Clear Press Event Counter (MC Button)', () => {
|
|
797
|
-
expect(commandBuilder.build('ClearPressEventCounter', { value: 1 })).toStrictEqual(
|
|
798
|
-
new BaseCommand('ClearPressEventCounter', 0x20, '01'),
|
|
799
|
-
)
|
|
800
|
-
})
|
|
801
|
-
|
|
802
|
-
test('Restart Device', () => {
|
|
803
|
-
expect(commandBuilder.build('RestartDevice')).toStrictEqual(new BaseCommand('RestartDevice', 0xa5))
|
|
804
|
-
})
|
|
805
|
-
})
|
|
806
|
-
describe('CO2 PIR Lite Commands payload encoder', () => {
|
|
807
|
-
const commandBuilder = new CommandBuilder('co2_pir_lite')
|
|
808
|
-
test('Set CO2 Measurement Time', () => {
|
|
809
|
-
expect(
|
|
810
|
-
commandBuilder.build('SetCo2MeasurementPeriod', { good_zone: 10, medium_zone: 20, bad_zone: 30 }),
|
|
811
|
-
).toStrictEqual(new BaseCommand('SetCo2MeasurementPeriod', 0x24, '0A', '14', '1E'))
|
|
812
|
-
})
|
|
813
|
-
test('Set PIR Sensor State (CO2 PIR Lite)', () => {
|
|
814
|
-
expect(commandBuilder.build('SetPIRSensorState', { state: 1 })).toStrictEqual(
|
|
815
|
-
new BaseCommand('SetPIRSensorState', 0x36, '01'),
|
|
816
|
-
)
|
|
817
|
-
})
|
|
818
|
-
test('Set Occupancy Timeout', () => {
|
|
819
|
-
expect(commandBuilder.build('SetOccupancyTimeout', { timeout: 60 })).toStrictEqual(
|
|
820
|
-
new BaseCommand('SetOccupancyTimeout', 0x38, '003C'),
|
|
821
|
-
)
|
|
822
|
-
})
|
|
823
|
-
test('Restart Device', () => {
|
|
824
|
-
expect(commandBuilder.build('RestartDevice')).toStrictEqual(new BaseCommand('RestartDevice', 0xa5))
|
|
825
|
-
})
|
|
826
|
-
})
|
|
827
|
-
describe('HT PIR Lite Commands payload encoder', () => {
|
|
828
|
-
const commandBuilder = new CommandBuilder('ht_pir_lite')
|
|
829
|
-
test('Set PIR Sensor state (HT PIR Lite)', () => {
|
|
830
|
-
expect(commandBuilder.build('SetPIRSensorState', { state: 1 })).toStrictEqual(
|
|
831
|
-
new BaseCommand('SetPIRSensorState', 0x36, '01'),
|
|
832
|
-
)
|
|
833
|
-
})
|
|
834
|
-
test('Set Occupancy Timeout', () => {
|
|
835
|
-
expect(commandBuilder.build('SetOccupancyTimeout', { timeout: 60 })).toStrictEqual(
|
|
836
|
-
new BaseCommand('SetOccupancyTimeout', 0x38, '003C'),
|
|
837
|
-
)
|
|
838
|
-
})
|
|
839
|
-
test('Restart Device', () => {
|
|
840
|
-
expect(commandBuilder.build('RestartDevice')).toStrictEqual(new BaseCommand('RestartDevice', 0xa5))
|
|
841
|
-
})
|
|
842
|
-
})
|
|
843
|
-
describe('Melissa Commands payload encoder', () => {
|
|
844
|
-
const commandBuilder = new CommandBuilder('melissa_lorawan')
|
|
845
|
-
test('Set IR Code Recording (Melissa)', () => {
|
|
846
|
-
expect(commandBuilder.build('SetIrCodeRecording', { time: 15, position: 0 })).toStrictEqual(
|
|
847
|
-
new BaseCommand('SetIrCodeRecording', 0x09, '0F', '00'),
|
|
848
|
-
)
|
|
849
|
-
})
|
|
850
|
-
})
|