Commit 62748eef60b163ab439a6b1f81675e4769152790
Committed by
Andrew Shvayka
1 parent
14230744
added deviceCreationTime to the DeviceStateData
Showing
2 changed files
with
4 additions
and
3 deletions
@@ -393,7 +393,7 @@ public class DefaultDeviceStateService implements DeviceStateService { | @@ -393,7 +393,7 @@ public class DefaultDeviceStateService implements DeviceStateService { | ||
393 | if (stateData != null) { | 393 | if (stateData != null) { |
394 | DeviceState state = stateData.getState(); | 394 | DeviceState state = stateData.getState(); |
395 | state.setActive(ts < state.getLastActivityTime() + state.getInactivityTimeout()); | 395 | state.setActive(ts < state.getLastActivityTime() + state.getInactivityTimeout()); |
396 | - if (!state.isActive() && (state.getLastInactivityAlarmTime() == 0L || state.getLastInactivityAlarmTime() < state.getLastActivityTime()) && UUIDs.unixTimestamp(deviceId.getId()) + state.getInactivityTimeout() < ts) { | 396 | + if (!state.isActive() && (state.getLastInactivityAlarmTime() == 0L || state.getLastInactivityAlarmTime() < state.getLastActivityTime()) && stateData.getDeviceCreationTime() + state.getInactivityTimeout() < ts) { |
397 | state.setLastInactivityAlarmTime(ts); | 397 | state.setLastInactivityAlarmTime(ts); |
398 | pushRuleEngineMessage(stateData, INACTIVITY_EVENT); | 398 | pushRuleEngineMessage(stateData, INACTIVITY_EVENT); |
399 | save(deviceId, INACTIVITY_ALARM_TIME, ts); | 399 | save(deviceId, INACTIVITY_ALARM_TIME, ts); |
@@ -480,6 +480,7 @@ public class DefaultDeviceStateService implements DeviceStateService { | @@ -480,6 +480,7 @@ public class DefaultDeviceStateService implements DeviceStateService { | ||
480 | return DeviceStateData.builder() | 480 | return DeviceStateData.builder() |
481 | .tenantId(device.getTenantId()) | 481 | .tenantId(device.getTenantId()) |
482 | .deviceId(device.getId()) | 482 | .deviceId(device.getId()) |
483 | + .deviceCreationTime(device.getCreatedTime()) | ||
483 | .metaData(md) | 484 | .metaData(md) |
484 | .state(deviceState).build(); | 485 | .state(deviceState).build(); |
485 | } catch (Exception e) { | 486 | } catch (Exception e) { |
@@ -30,8 +30,8 @@ class DeviceStateData { | @@ -30,8 +30,8 @@ class DeviceStateData { | ||
30 | 30 | ||
31 | private final TenantId tenantId; | 31 | private final TenantId tenantId; |
32 | private final DeviceId deviceId; | 32 | private final DeviceId deviceId; |
33 | - | 33 | + private final long deviceCreationTime; |
34 | private TbMsgMetaData metaData; | 34 | private TbMsgMetaData metaData; |
35 | private final DeviceState state; | 35 | private final DeviceState state; |
36 | - | 36 | + |
37 | } | 37 | } |