Commit 62748eef60b163ab439a6b1f81675e4769152790

Authored by YevhenBondarenko
Committed by Andrew Shvayka
1 parent 14230744

added deviceCreationTime to the DeviceStateData

... ... @@ -393,7 +393,7 @@ public class DefaultDeviceStateService implements DeviceStateService {
393 393 if (stateData != null) {
394 394 DeviceState state = stateData.getState();
395 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 397 state.setLastInactivityAlarmTime(ts);
398 398 pushRuleEngineMessage(stateData, INACTIVITY_EVENT);
399 399 save(deviceId, INACTIVITY_ALARM_TIME, ts);
... ... @@ -480,6 +480,7 @@ public class DefaultDeviceStateService implements DeviceStateService {
480 480 return DeviceStateData.builder()
481 481 .tenantId(device.getTenantId())
482 482 .deviceId(device.getId())
  483 + .deviceCreationTime(device.getCreatedTime())
483 484 .metaData(md)
484 485 .state(deviceState).build();
485 486 } catch (Exception e) {
... ...
... ... @@ -30,8 +30,8 @@ class DeviceStateData {
30 30
31 31 private final TenantId tenantId;
32 32 private final DeviceId deviceId;
33   -
  33 + private final long deviceCreationTime;
34 34 private TbMsgMetaData metaData;
35 35 private final DeviceState state;
36   -
  36 +
37 37 }
... ...