@Override
    public void onMessageReceived(StateDeviceProtos.StateDeviceMessage msg) {
      if (msg != null && msg.getType() == StateDeviceProtos.StateDeviceMessage.Type.DOORBELL) {

        Log.i(TAG, "New message received");

        // create a device from the message
        StateDevice device = new StateDevice(msg);

        if (StateDeviceManager.contains(msg.getId())) {
          // update the device
          StateDeviceManager.updateStateDevice(device);
        } else {
          // add the device
          StateDeviceManager.addStateDevice(device);
        }

        // notification and save image
        if (msg.getType() == StateDeviceProtos.StateDeviceMessage.Type.DOORBELL) {
          if (msg.hasData()) {
            Notifications.sendDoorbellAlertNotification(mContext, msg);
            saveVisitor(msg);
          } else {
            Log.i(TAG, msg.toString());
          }
        }
      }
    }