Search in sources :

Example 1 with DeviceNameOrTypeUpdateMsg

use of org.thingsboard.rule.engine.api.msg.DeviceNameOrTypeUpdateMsg in project thingsboard by thingsboard.

the class DefaultTbClusterService method onDeviceUpdated.

@Override
public void onDeviceUpdated(Device device, Device old, boolean notifyEdge) {
    var created = old == null;
    broadcastEntityChangeToTransport(device.getTenantId(), device.getId(), device, null);
    if (old != null) {
        boolean deviceNameChanged = !device.getName().equals(old.getName());
        if (deviceNameChanged) {
            gatewayNotificationsService.onDeviceUpdated(device, old);
        }
        if (deviceNameChanged || !device.getType().equals(old.getType())) {
            pushMsgToCore(new DeviceNameOrTypeUpdateMsg(device.getTenantId(), device.getId(), device.getName(), device.getType()), null);
        }
    }
    broadcastEntityStateChangeEvent(device.getTenantId(), device.getId(), created ? ComponentLifecycleEvent.CREATED : ComponentLifecycleEvent.UPDATED);
    sendDeviceStateServiceEvent(device.getTenantId(), device.getId(), created, !created, false);
    otaPackageStateService.update(device, old);
    if (!created && notifyEdge) {
        sendNotificationMsgToEdgeService(device.getTenantId(), null, device.getId(), null, null, EdgeEventActionType.UPDATED);
    }
}
Also used : DeviceNameOrTypeUpdateMsg(org.thingsboard.rule.engine.api.msg.DeviceNameOrTypeUpdateMsg)

Aggregations

DeviceNameOrTypeUpdateMsg (org.thingsboard.rule.engine.api.msg.DeviceNameOrTypeUpdateMsg)1