dt-common-device 4.0.2 → 4.0.3
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.
|
@@ -131,6 +131,7 @@ let DeviceRepository = (() => {
|
|
|
131
131
|
async getState(deviceId) {
|
|
132
132
|
try {
|
|
133
133
|
const response = await this.axiosInstance.get(`/devices/${deviceId}/state`);
|
|
134
|
+
console.log("GetState response:------------", response.data);
|
|
134
135
|
return response.data;
|
|
135
136
|
}
|
|
136
137
|
catch (error) {
|
|
@@ -144,7 +145,7 @@ let DeviceRepository = (() => {
|
|
|
144
145
|
return response.data;
|
|
145
146
|
}
|
|
146
147
|
catch (error) {
|
|
147
|
-
(0, config_1.getConfig)().LOGGER.error(`Failed to set device state for ${deviceId}
|
|
148
|
+
(0, config_1.getConfig)().LOGGER.error(`Failed to set device state for ${deviceId}: ${error.message}`);
|
|
148
149
|
throw new Error(`Failed to set device state: ${error.message || "Unknown error"}`);
|
|
149
150
|
}
|
|
150
151
|
}
|
|
@@ -118,7 +118,7 @@ let LocalDeviceService = (() => {
|
|
|
118
118
|
throw new Error("Device ID and new state are required");
|
|
119
119
|
}
|
|
120
120
|
// If old state and new state are different
|
|
121
|
-
const oldState = (await this.getState(deviceId))?.
|
|
121
|
+
const oldState = (await this.getState(deviceId))?.state ?? {};
|
|
122
122
|
const changedKeys = Object.keys(newState).filter((key) => !(0, lodash_1.isEqual)(oldState[key], newState[key]));
|
|
123
123
|
if (changedKeys.length > 0) {
|
|
124
124
|
await this.deviceRepository.setState(deviceId, newState);
|