Commit 1423074485e2c94717f01dcbe98608da79c72a13
Committed by
Andrew Shvayka
1 parent
03564318
fixed sending inactivity event after device creation.
Showing
1 changed file
with
2 additions
and
1 deletions
... | ... | @@ -15,6 +15,7 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.server.service.state; |
17 | 17 | |
18 | +import com.datastax.driver.core.utils.UUIDs; | |
18 | 19 | import com.fasterxml.jackson.databind.node.ObjectNode; |
19 | 20 | import com.google.common.base.Function; |
20 | 21 | import com.google.common.util.concurrent.FutureCallback; |
... | ... | @@ -392,7 +393,7 @@ public class DefaultDeviceStateService implements DeviceStateService { |
392 | 393 | if (stateData != null) { |
393 | 394 | DeviceState state = stateData.getState(); |
394 | 395 | state.setActive(ts < state.getLastActivityTime() + state.getInactivityTimeout()); |
395 | - if (!state.isActive() && (state.getLastInactivityAlarmTime() == 0L || state.getLastInactivityAlarmTime() < state.getLastActivityTime())) { | |
396 | + if (!state.isActive() && (state.getLastInactivityAlarmTime() == 0L || state.getLastInactivityAlarmTime() < state.getLastActivityTime()) && UUIDs.unixTimestamp(deviceId.getId()) + state.getInactivityTimeout() < ts) { | |
396 | 397 | state.setLastInactivityAlarmTime(ts); |
397 | 398 | pushRuleEngineMessage(stateData, INACTIVITY_EVENT); |
398 | 399 | save(deviceId, INACTIVITY_ALARM_TIME, ts); | ... | ... |