sinricpro 2.9.1 → 2.10.1
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/lib/cbhandler.js
CHANGED
|
@@ -10,7 +10,7 @@ const { powerState, powerLevel, powerLevelAdjust } = require('./contorllers/powe
|
|
|
10
10
|
const { Brightness, BrightnessAdjust } = require('./contorllers/brightness_controller');
|
|
11
11
|
const { Color } = require('./contorllers/color_controller');
|
|
12
12
|
const { ColorTemperature } = require('./contorllers/color_temperature');
|
|
13
|
-
const { ThermoStatMode, ThermoStatTemperature, Lock } = require('./contorllers/sensors_controller');
|
|
13
|
+
const { ThermoStatMode, ThermoStatTemperature, Lock, AdjustTargetTemperature } = require('./contorllers/sensors_controller');
|
|
14
14
|
const { RangeValue, RangeValueAdjust } = require('./contorllers/range_value_controller');
|
|
15
15
|
const { Volume, VolumeAdjust, Mute } = require('./contorllers/tv_controller');
|
|
16
16
|
const { ChangeChannel, SkipChannel, Media } = require('./contorllers/tv_controller');
|
|
@@ -45,6 +45,7 @@ const jsonResponse = (client, defaultPayload, payloadValue, instanceId) => {
|
|
|
45
45
|
const signature = {
|
|
46
46
|
HMAC: getSignature(client, JSON.stringify(payload)),
|
|
47
47
|
};
|
|
48
|
+
|
|
48
49
|
return { header, payload, signature };
|
|
49
50
|
};
|
|
50
51
|
|
|
@@ -165,6 +166,13 @@ const handlePayload = (client, payload, signature, callbacks) => verifySignature
|
|
|
165
166
|
return CameraStreamController(payload, callbacks)
|
|
166
167
|
.then((offer) => jsonResponse(client, payload, { offer }))
|
|
167
168
|
.catch(handleError);
|
|
169
|
+
} else if (action === 'adjustTargetTemperature') {
|
|
170
|
+
return AdjustTargetTemperature(payload, callbacks)
|
|
171
|
+
.then((resp) => {
|
|
172
|
+
const { temperature } = resp;
|
|
173
|
+
return jsonResponse(client, payload, temperature);
|
|
174
|
+
})
|
|
175
|
+
.catch(handleError);
|
|
168
176
|
}
|
|
169
177
|
return {};
|
|
170
178
|
})
|
|
@@ -31,6 +31,16 @@ const ThermoStatTemperature = async (payload, callbacks) => {
|
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
+
const AdjustTargetTemperature = async (payload, callbacks) => {
|
|
35
|
+
if (callbacks.adjustTargetTemperature) {
|
|
36
|
+
const resp = await callbacks.adjustTargetTemperature(payload.deviceId, payload.value.temperature);
|
|
37
|
+
if (resp.temperature) return resp;
|
|
38
|
+
throw new InvalidResponseError('Thermostat temperature undefined');
|
|
39
|
+
} else {
|
|
40
|
+
throw new UndefinedCallbackError('adjustTargetTemperature callback is undefined.');
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
34
44
|
const Lock = async (payload, callbacks) => {
|
|
35
45
|
if (callbacks.setLockState) {
|
|
36
46
|
const resp = await callbacks.setLockState(payload.deviceId, payload.value.state);
|
|
@@ -41,4 +51,4 @@ const Lock = async (payload, callbacks) => {
|
|
|
41
51
|
}
|
|
42
52
|
};
|
|
43
53
|
|
|
44
|
-
module.exports = { ThermoStatMode, ThermoStatTemperature, Lock };
|
|
54
|
+
module.exports = { ThermoStatMode, ThermoStatTemperature, Lock, AdjustTargetTemperature };
|