process ALARM_ACK msg in device state
This commit is contained in:
parent
c1223b0c10
commit
24ebc06fa4
@ -291,4 +291,11 @@ class AlarmState {
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
||||
public void processAckAlarm(Alarm alarm) {
|
||||
if (currentAlarm != null && currentAlarm.getId().equals(alarm.getId())) {
|
||||
currentAlarm.setStatus(alarm.getStatus());
|
||||
currentAlarm.setAckTs(alarm.getAckTs());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,6 +140,8 @@ class DeviceState {
|
||||
stateChanged = processAttributesDeleteNotification(ctx, msg);
|
||||
} else if (msg.getType().equals(DataConstants.ALARM_CLEAR)) {
|
||||
stateChanged = processAlarmClearNotification(ctx, msg);
|
||||
} else if (msg.getType().equals(DataConstants.ALARM_ACK)) {
|
||||
processAlarmAckNotification(ctx, msg);
|
||||
} else {
|
||||
ctx.tellSuccess(msg);
|
||||
}
|
||||
@ -161,6 +163,16 @@ class DeviceState {
|
||||
return stateChanged;
|
||||
}
|
||||
|
||||
private void processAlarmAckNotification(TbContext ctx, TbMsg msg) {
|
||||
Alarm alarmNf = JacksonUtil.fromString(msg.getData(), Alarm.class);
|
||||
for (DeviceProfileAlarm alarm : deviceProfile.getAlarmSettings()) {
|
||||
AlarmState alarmState = alarmStates.computeIfAbsent(alarm.getId(),
|
||||
a -> new AlarmState(this.deviceProfile, deviceId, alarm, getOrInitPersistedAlarmState(alarm)));
|
||||
alarmState.processAckAlarm(alarmNf);
|
||||
}
|
||||
ctx.tellSuccess(msg);
|
||||
}
|
||||
|
||||
private boolean processAttributesUpdateNotification(TbContext ctx, TbMsg msg) throws ExecutionException, InterruptedException {
|
||||
Set<AttributeKvEntry> attributes = JsonConverter.convertToAttributes(new JsonParser().parse(msg.getData()));
|
||||
String scope = msg.getMetaData().getValue("scope");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user